Android Studio报错:
What went wrong:
Execution failed for task ':app:processDebugManifest'.
> 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 <application> element at AndroidManifest.xml:10:5-24:19 to override.
意思就是说:
value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.0.0] 跟
value=(android.support.v4.app.CoreComponentFactory)
起冲突了,我在项目里引用的是:
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
解决方案请看这篇文章:
AndroidStudio报错Manifest merger failed : Attribute application@appComponentFactory value=(android.sup
解决方案:
在清单文件 添加如下代码
<application
...
android:theme="@style/AppTheme"
android:appComponentFactory=""
tools:replace="android:appComponentFactory">
我有两个项目都出现此问题了,第一个项目加入以上,就顺利解决了,但是第二个项目加入以后仍然报错:
Error:FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
仔细查看发现app的build.gradle文件出现问题了,这是有问题的:
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
发现在编译的时候,不知道怎么就导入了最后两行,很明显跟第一行起冲突了,把最后两行删掉就行了,改后如下:
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly'