RGS
RGS

Reputation: 4253

play-services-ads:18.0.0 and appcompat-v7:28.0.0 - merger failed and dependencies using groupid com.android.support and androidx.* can not be combined

I have an early version of play service and it was ok. Now I update it to 18.0.0 and have many errors:

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:8:5-35:15 to override.

my dependencies:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.anjlab.android.iab.v3:library:1.0.44'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.android.gms:play-services-ads:18.0.0'
}

configurations.all {
    resolutionStrategy.eachDependency {  details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "28.0.0"
            }
        }
    }
}

the implementation 'com.android.support:appcompat-v7:28.0.0' is underline in red saying that dependencies using groupid com.android.support and androidx.* can not be combined.

any ideas how to solve this errors?

Upvotes: 2

Views: 761

Answers (1)

guipivoto
guipivoto

Reputation: 18687

This issue is happening because latest versions of com.google.android.gms:play-services-ads (in this case v18.0.0) is already using AndroidX but your app is still using Android Support.

So, there are two possibilities:

  • Downgrade com.google.android.gms:play-services-ads

If you downgrade the version of that library, this issue should be fixed because old versions were still using Support Library (and not AndroidX).

You can try for example:

com.google.android.gms:play-services-ads:17.2.0

HERE you can find the list of released versions

  • You should consider to migrate your app to AndroidX.

Support Library was deprecated. So, sooner or later, you will have to move to AndroidX. If do so, errors like this won't happen.

Upvotes: 4

Related Questions