SOLVE : Manifest merger failed : Attribute application@appComponentFactory

在将butterknife升级到10.0.0的时候遇到问题,编译无法通过。

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 <application> element at AndroidManifest.xml:11:5-34:19 to override.

经过查阅资料后得知是butterknife在10.0.0的时候引用的AndroidX,而AndroidX无法与support支持包共存导致了该错误。谷歌在api28之后将不在提供support的支持包。以后将使用AndroidX来整合代替。

butterknife的issue.png

解决方法1

在gradle.properties中添加如下

suppport_library_version=28.0.0
android.useDeprecatedNdk=true
android.useAndroidX=true
android.enableJetifier=true

如图所示.png

解决方法2

  • 需要你的项目build.gradle中的插件版本要在3.2.0以上
    改变所有import:support支持包为androidx.png

作者:冬絮
链接:https://www.jianshu.com/p/504857b51e93
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

Leave a Comment