play-services-ads:18.0.0和appcompat-v7:28.0.0-合并失败,并且使用groupid com.android.support和androidx.*的依赖项无法合并 [英] 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

查看:894
本文介绍了play-services-ads:18.0.0和appcompat-v7:28.0.0-合并失败,并且使用groupid com.android.support和androidx.*的依赖项无法合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有早期版本的Play服务,还可以. 现在,我将其更新为18.0.0,并出现许多错误:

清单合并失败:属性application @ appComponentFactory 值=(android.support.v4.app.CoreComponentFactory)来自 [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91也存在于 [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 值=(androidx.core.app.CoreComponentFactory).意见建议:添加 'tools:replace ="android:appComponentFactory"'转换为元素 在AndroidManifest.xml:8:5-35:15进行覆盖.

我的依赖项:

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"
            }
        }
    }
}

implementation 'com.android.support:appcompat-v7:28.0.0'用红色下划线表示无法将使用groupid com.android.support和androidx.*的依赖项组合在一起.

有什么办法解决这个错误吗?

解决方案

之所以会出现此问题,是因为最新版本的com.google.android.gms:play-services-ads(在本例中为v18.0.0)已经在使用AndroidX,但是您的应用仍在使用Android支持./p>

因此,有两种可能性:

  • 降级com.google.android.gms:play-services-ads

如果您降级该库的版本,则应解决此问题,因为旧版本仍在使用支持库(而非AndroidX).

您可以尝试例如:

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

这里,您可以查找已发布版本的列表

  • 您应该考虑将您的应用迁移到AndroidX.

不推荐使用支持库.因此,迟早您将不得不转向AndroidX.如果这样做,将不会发生这样的错误.

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?

解决方案

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.

这篇关于play-services-ads:18.0.0和appcompat-v7:28.0.0-合并失败,并且使用groupid com.android.support和androidx.*的依赖项无法合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆