提问人:RGS 提问时间:7/11/2019 最后编辑:Gabriele MariottiRGS 更新时间:7/24/2019 访问量:747
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
问:
我有一个早期版本的游戏服务,还可以。 现在我将其更新到 18.0.0 并出现许多错误:
清单合并失败:属性application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) 来自 [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 也存在于 [androidx.core:核心:1.0.0]Android清单.xml:22:18-86 value=(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"
}
}
}
}
红色下划线表示不能合并使用 groupid、com.android.support 和 androidx.* 的依赖项。implementation 'com.android.support:appcompat-v7:28.0.0'
有什么想法如何解决这个错误吗?
答:
出现此问题的原因是最新版本(在本例中)已在使用 AndroidX,但您的应用仍在使用 Android 支持。com.google.android.gms:play-services-ads
v18.0.0
因此,有两种可能性:
- 降级
com.google.android.gms:play-services-ads
如果您降级该库的版本,则此问题应该会得到解决,因为旧版本仍在使用支持库(而不是 AndroidX)。
例如,您可以尝试:
com.google.android.gms:play-services-ads:17.2.0
在这里,您可以找到已发布版本的列表
- 您应该考虑将您的应用程序迁移到 AndroidX。
支持库已弃用。因此,迟早,您将不得不迁移到AndroidX。如果这样做,就不会发生这样的错误。
评论