当前位置:   article > 正文

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

manifest merger failed : attribute application@appcomponentfactory value=(an

Android Studio报错:

  1. What went wrong:
  2. Execution failed for task ':app:processDebugManifest'.
  3. > Manifest merger failed : Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86
  4. is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).
  5. 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)

起冲突了,我在项目里引用的是:

  1. implementation 'androidx.appcompat:appcompat:1.0.0'
  2. implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
  3. implementation 'com.google.android.material:material:1.0.0'

解决方案请看这篇文章:

AndroidStudio报错Manifest merger failed : Attribute application@appComponentFactory value=(android.sup

解决方案:

在清单文件 添加如下代码

  1. <application
  2. ...
  3. android:theme="@style/AppTheme"
  4. android:appComponentFactory=""
  5. tools:replace="android:appComponentFactory">

我有两个项目都出现此问题了,第一个项目加入以上,就顺利解决了,但是第二个项目加入以后仍然报错:

  1. Error:FAILURE: Build failed with an exception.
  2. * What went wrong:
  3. Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
  4. > java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
  5. * Try:
  6. 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.
  7. * Get more help at https://help.gradle.org
  8. BUILD FAILED in 1s

仔细查看发现app的build.gradle文件出现问题了,这是有问题的:

  1. implementation 'androidx.appcompat:appcompat:1.0.0'
  2. implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
  3. implementation 'com.google.android.material:material:1.0.0'
  4. implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly'
  5. implementation 'com.android.support:appcompat-v7:28.0.0'
  6. implementation 'com.android.support.constraint:constraint-layout:1.1.3'

发现在编译的时候,不知道怎么就导入了最后两行,很明显跟第一行起冲突了,把最后两行删掉就行了,改后如下:

  1. implementation 'androidx.appcompat:appcompat:1.0.0'
  2. implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
  3. implementation 'com.google.android.material:material:1.0.0'
  4. implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly'

 

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/Guff_9hys/article/detail/824139
推荐阅读
相关标签
  

闽ICP备14008679号