Android Studio报错Manifest merger failed : Attribute application@appComponentFactory value

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'

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值