ERROR: Manifest merger failed : Attribute application@appComponentFactory value=

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

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:36:5-364:19 to override.
 

原因包冲突

网上有说添加

tools:replace="android:appComponentFactory"

然后又报错

Error:
	tools:replace specified at line:15 for attribute android:appComponentFactory, but no new value specified

继续添加

android:appComponentFactory="android.support.v4.app.CoreComponentFactory"

依然报错

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
  Program type already present: androidx.versionedparcelable.CustomVersionedParcelable

经过各种折腾,终于get到,Androidx和Android support库不能共存

解决方案一 转换成Androidx、这个不用多说了,但有些项目转换工作量巨大啊,自行考量

解决方案二 AndroidX转换成Android Support

1、查看那些库依赖了Androidx,执行gradlew :app:dependencies

我这里终于找到是哪个库依赖了Androidx

play-services-base

 

降低版本 运行就好; 

 

 

 

你可能感兴趣的:(Android开发技巧)