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

佐手、 提交于 2019-12-02 08:33:37

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/56988906/play-services-ads18-0-0-and-appcompat-v728-0-0-merger-failed-and-dependencie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!