react-native 编译出错 —— Manifest merger failed

Manifest merger failed —— Androidx

中间尝试了很多方式,都不行!比如

manifest/application中添加
android:appComponentFactory="" tools:replace="android:appComponentFactory"

或者

gradle.properties中写入
android.useAndroidX=true android.enableJetifier=true

错误展示

在这里插入图片描述

  • What went wrong:
    Execution failed for task ‘:app:processDebugManifest’.
    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:7:5-117 to override.

昨天项目好好的,今个一大早运行编译就报错!!
游遍整个 Internet 发现,竟然和 AndroidX 有毛关系!!!

定位错误原因

错误的原因: Androidx之前的安卓support库已经存在当前最新的Androidx support库中,他俩不能共存。而事实是共存了,因此编译时候就导致资源合并异常!
到底是怎么共存的?反正我在android/app的gradle中是没有引入。很容易猜想到libraries —— 引入的第三方库。是的!!

确定解决方案

接下来的解决思路是,怎么去查哪个库引入了Androidx的东西??然后去掉对Androidx的引用(去掉方式就是使用那个没引用Androidx的版本)

查看哪些库依赖了Androidx,在android目录下执行命令
cd android/ && ./gradlew :app:dependenciess

下面看下我的(翻到最后一个~)

releaseUnitTestRuntimeClasspath - Resolved configuration for runtime for variant: releaseUnitTest
+--- project :react-native-fast-image
|    +--- com.facebook.react:react-native:+ -> 0.59.9
|    |    +--- com.facebook.infer.annotation:infer-annotation:0.11.2
|    |    |    \--- com.google.code.findbugs:jsr305:3.0.1 -> 3.0.2
|    |    +--- javax.inject:javax.inject:1
|    |    +--- com.android.support:appcompat-v7:28.0.0
|    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:support-compat:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:collections:28.0.0
|    |    |    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- android.arch.lifecycle:runtime:1.1.1
|    |    |    |    |    +--- android.arch.lifecycle:common:1.1.1
|    |    |    |    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    |    |    +--- android.arch.core:common:1.1.1
|    |    |    |    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    |    \--- com.android.support:versionedparcelable:28.0.0
|    |    |    |         +--- com.android.support:support-annotations:28.0.0
|    |    |    |         \--- com.android.support:collections:28.0.0 (*)
|    |    |    +--- com.android.support:collections:28.0.0 (*)
|    |    |    +--- com.android.support:cursoradapter:28.0.0
|    |    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:support-core-utils:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    +--- com.android.support:documentfile:28.0.0
|    |    |    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:loader:28.0.0
|    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    |    +--- android.arch.lifecycle:livedata:1.1.1
|    |    |    |    |    |    +--- android.arch.core:runtime:1.1.1
|    |    |    |    |    |    |    +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    |    |    |    |    \--- android.arch.core:common:1.1.1 (*)
|    |    |    |    |    |    +--- android.arch.lifecycle:livedata-core:1.1.1
|    |    |    |    |    |    |    +--- android.arch.lifecycle:common:1.1.1 (*)
|    |    |    |    |    |    |    +--- android.arch.core:common:1.1.1 (*)
|    |    |    |    |    |    |    \--- android.arch.core:runtime:1.1.1 (*)
|    |    |    |    |    |    \--- android.arch.core:common:1.1.1 (*)
|    |    |    |    |    \--- android.arch.lifecycle:viewmodel:1.1.1
|    |    |    |    |         \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    |    +--- com.android.support:localbroadcastmanager:28.0.0
|    |    |    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    |    |    \--- com.android.support:print:28.0.0
|    |    |    |         \--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:support-fragment:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    +--- com.android.support:support-core-ui:28.0.0
|    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    |    +--- com.android.support:support-core-utils:28.0.0 (*)
|    |    |    |    |    +--- com.android.support:customview:28.0.0
|    |    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    |    \--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    |    +--- com.android.support:viewpager:28.0.0
|    |    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    |    |    +--- com.android.support:coordinatorlayout:28.0.0
|    |    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    |    |    +--- com.android.support:drawerlayout:28.0.0
|    |    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    |    |    +--- com.android.support:slidingpanelayout:28.0.0
|    |    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    |    |    +--- com.android.support:interpolator:28.0.0
|    |    |    |    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    +--- com.android.support:swiperefreshlayout:28.0.0
|    |    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    |    |    \--- com.android.support:interpolator:28.0.0 (*)
|    |    |    |    |    +--- com.android.support:asynclayoutinflater:28.0.0
|    |    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    |    \--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    |    \--- com.android.support:cursoradapter:28.0.0 (*)
|    |    |    |    +--- com.android.support:support-core-utils:28.0.0 (*)
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:loader:28.0.0 (*)
|    |    |    |    \--- android.arch.lifecycle:viewmodel:1.1.1 (*)
|    |    |    +--- com.android.support:support-vector-drawable:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    \--- com.android.support:support-compat:28.0.0 (*)
|    |    |    \--- com.android.support:animated-vector-drawable:28.0.0
|    |    |         +--- com.android.support:support-vector-drawable:28.0.0 (*)
|    |    |         \--- com.android.support:support-core-ui:28.0.0 (*)
|    |    +--- com.facebook.fresco:fresco:1.10.0
|    |    |    +--- com.facebook.fresco:fbcore:1.10.0
|    |    |    +--- com.facebook.fresco:drawee:1.10.0
|    |    |    |    +--- com.facebook.fresco:fbcore:1.10.0
|    |    |    |    \--- com.facebook.fresco:imagepipeline:1.10.0
|    |    |    |         +--- com.facebook.fresco:imagepipeline-base:1.10.0
|    |    |    |         |    +--- com.facebook.soloader:soloader:0.5.0 -> 0.6.0
|    |    |    |         |    +--- com.parse.bolts:bolts-tasks:1.4.0
|    |    |    |         |    \--- com.facebook.fresco:fbcore:1.10.0
|    |    |    |         +--- com.facebook.soloader:soloader:0.5.0 -> 0.6.0
|    |    |    |         +--- com.parse.bolts:bolts-tasks:1.4.0
|    |    |    |         \--- com.facebook.fresco:fbcore:1.10.0
|    |    |    +--- com.facebook.fresco:imagepipeline:1.10.0 (*)
|    |    |    \--- com.facebook.soloader:soloader:0.5.0 -> 0.6.0
|    |    +--- com.facebook.fresco:imagepipeline-okhttp3:1.10.0
|    |    |    +--- com.squareup.okhttp3:okhttp:3.10.0 -> 3.12.1
|    |    |    |    \--- com.squareup.okio:okio:1.15.0
|    |    |    +--- com.facebook.fresco:fbcore:1.10.0
|    |    |    \--- com.facebook.fresco:imagepipeline:1.10.0 (*)
|    |    +--- com.facebook.soloader:soloader:0.6.0
|    |    +--- com.google.code.findbugs:jsr305:3.0.2
|    |    +--- com.squareup.okhttp3:okhttp:3.12.1 (*)
|    |    +--- com.squareup.okhttp3:okhttp-urlconnection:3.12.1
|    |    |    \--- com.squareup.okhttp3:okhttp:3.12.1 (*)
|    |    \--- com.squareup.okio:okio:1.15.0
|    +--- com.android.support:support-v4:28.0.0
|    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    +--- com.android.support:support-media-compat:28.0.0
|    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    \--- com.android.support:versionedparcelable:28.0.0 (*)
|    |    +--- com.android.support:support-core-utils:28.0.0 (*)
|    |    +--- com.android.support:support-core-ui:28.0.0 (*)
|    |    \--- com.android.support:support-fragment:28.0.0 (*)
|    +--- com.github.bumptech.glide:glide:4.7.1
|    |    +--- com.github.bumptech.glide:gifdecoder:4.7.1
|    |    |    \--- com.android.support:support-annotations:27.1.1 -> 28.0.0
|    |    +--- com.github.bumptech.glide:disklrucache:4.7.1
|    |    +--- com.github.bumptech.glide:annotations:4.7.1
|    |    \--- com.android.support:support-fragment:27.1.1 -> 28.0.0 (*)
|    +--- com.github.bumptech.glide:annotations:4.7.1
|    \--- com.github.bumptech.glide:okhttp3-integration:4.7.1
|         +--- com.github.bumptech.glide:glide:4.7.1 (*)
|         +--- com.squareup.okhttp3:okhttp:3.9.1 -> 3.12.1 (*)
|         \--- com.android.support:support-annotations:27.1.1 -> 28.0.0
+--- project :react-native-gesture-handler
+--- project :react-native-wechat
|    \--- com.facebook.react:react-native:+ -> 0.59.9 (*)
+--- project :react-native-code-push
|    +--- com.facebook.react:react-native:+ -> 0.59.9 (*)
|    \--- com.nimbusds:nimbus-jose-jwt:5.1
|         +--- com.github.stephenc.jcip:jcip-annotations:1.0-1
|         \--- net.minidev:json-smart:[1.3.1,2.3] -> 2.3
|              \--- net.minidev:accessors-smart:1.2
|                   \--- org.ow2.asm:asm:5.0.4
+--- project :react-native-device-info
|    +--- com.facebook.react:react-native:+ -> 0.59.9 (*)
|    \--- com.google.android.gms:play-services-gcm:+ -> 17.0.0
|         +--- androidx.collection:collection:1.0.0
|         |    \--- androidx.annotation:annotation:1.0.0
|         +--- androidx.core:core:1.0.0
|         |    +--- androidx.annotation:annotation:1.0.0
|         |    +--- androidx.collection:collection:1.0.0 (*)
|         |    +--- androidx.lifecycle:lifecycle-runtime:2.0.0
|         |    |    +--- androidx.lifecycle:lifecycle-common:2.0.0
|         |    |    |    \--- androidx.annotation:annotation:1.0.0
|         |    |    +--- androidx.arch.core:core-common:2.0.0
|         |    |    |    \--- androidx.annotation:annotation:1.0.0
|         |    |    \--- androidx.annotation:annotation:1.0.0
|         |    \--- androidx.versionedparcelable:versionedparcelable:1.0.0
|         |         +--- androidx.annotation:annotation:1.0.0
|         |         \--- androidx.collection:collection:1.0.0 (*)
|         +--- androidx.legacy:legacy-support-core-utils:1.0.0
|         |    +--- androidx.annotation:annotation:1.0.0
|         |    +--- androidx.core:core:1.0.0 (*)
|         |    +--- androidx.documentfile:documentfile:1.0.0
|         |    |    \--- androidx.annotation:annotation:1.0.0
|         |    +--- androidx.loader:loader:1.0.0
|         |    |    +--- androidx.annotation:annotation:1.0.0
|         |    |    +--- androidx.core:core:1.0.0 (*)
|         |    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0
|         |    |    |    +--- androidx.arch.core:core-runtime:2.0.0
|         |    |    |    |    +--- androidx.annotation:annotation:1.0.0
|         |    |    |    |    \--- androidx.arch.core:core-common:2.0.0 (*)
|         |    |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.0.0
|         |    |    |    |    +--- androidx.lifecycle:lifecycle-common:2.0.0 (*)
|         |    |    |    |    +--- androidx.arch.core:core-common:2.0.0 (*)
|         |    |    |    |    \--- androidx.arch.core:core-runtime:2.0.0 (*)
|         |    |    |    \--- androidx.arch.core:core-common:2.0.0 (*)
|         |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0
|         |    |         \--- androidx.annotation:annotation:1.0.0
|         |    +--- androidx.localbroadcastmanager:localbroadcastmanager:1.0.0
|         |    |    \--- androidx.annotation:annotation:1.0.0
|         |    \--- androidx.print:print:1.0.0
|         |         \--- androidx.annotation:annotation:1.0.0
|         +--- com.google.android.gms:play-services-base:17.0.0
|         |    +--- androidx.collection:collection:1.0.0 (*)
|         |    +--- androidx.core:core:1.0.0 (*)
|         |    +--- androidx.fragment:fragment:1.0.0
|         |    |    +--- androidx.core:core:1.0.0 (*)
|         |    |    +--- androidx.legacy:legacy-support-core-ui:1.0.0
|         |    |    |    +--- androidx.annotation:annotation:1.0.0
|         |    |    |    +--- androidx.core:core:1.0.0 (*)
|         |    |    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|         |    |    |    +--- androidx.customview:customview:1.0.0
|         |    |    |    |    +--- androidx.annotation:annotation:1.0.0
|         |    |    |    |    \--- androidx.core:core:1.0.0 (*)
|         |    |    |    +--- androidx.viewpager:viewpager:1.0.0
|         |    |    |    |    +--- androidx.annotation:annotation:1.0.0
|         |    |    |    |    +--- androidx.core:core:1.0.0 (*)
|         |    |    |    |    \--- androidx.customview:customview:1.0.0 (*)
|         |    |    |    +--- androidx.coordinatorlayout:coordinatorlayout:1.0.0
|         |    |    |    |    +--- androidx.annotation:annotation:1.0.0
|         |    |    |    |    +--- androidx.core:core:1.0.0 (*)
|         |    |    |    |    \--- androidx.customview:customview:1.0.0 (*)
|         |    |    |    +--- androidx.drawerlayout:drawerlayout:1.0.0
|         |    |    |    |    +--- androidx.annotation:annotation:1.0.0
|         |    |    |    |    +--- androidx.core:core:1.0.0 (*)
|         |    |    |    |    \--- androidx.customview:customview:1.0.0 (*)
|         |    |    |    +--- androidx.slidingpanelayout:slidingpanelayout:1.0.0
|         |    |    |    |    +--- androidx.annotation:annotation:1.0.0
|         |    |    |    |    +--- androidx.core:core:1.0.0 (*)
|         |    |    |    |    \--- androidx.customview:customview:1.0.0 (*)
|         |    |    |    +--- androidx.interpolator:interpolator:1.0.0
|         |    |    |    |    \--- androidx.annotation:annotation:1.0.0
|         |    |    |    +--- androidx.swiperefreshlayout:swiperefreshlayout:1.0.0
|         |    |    |    |    +--- androidx.annotation:annotation:1.0.0
|         |    |    |    |    +--- androidx.core:core:1.0.0 (*)
|         |    |    |    |    \--- androidx.interpolator:interpolator:1.0.0 (*)
|         |    |    |    +--- androidx.asynclayoutinflater:asynclayoutinflater:1.0.0
|         |    |    |    |    +--- androidx.annotation:annotation:1.0.0
|         |    |    |    |    \--- androidx.core:core:1.0.0 (*)
|         |    |    |    \--- androidx.cursoradapter:cursoradapter:1.0.0
|         |    |    |         \--- androidx.annotation:annotation:1.0.0
|         |    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|         |    |    +--- androidx.annotation:annotation:1.0.0
|         |    |    +--- androidx.loader:loader:1.0.0 (*)
|         |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0 (*)
|         |    +--- com.google.android.gms:play-services-basement:17.0.0
|         |    |    +--- androidx.collection:collection:1.0.0 (*)
|         |    |    +--- androidx.core:core:1.0.0 (*)
|         |    |    \--- androidx.fragment:fragment:1.0.0 (*)
|         |    \--- com.google.android.gms:play-services-tasks:17.0.0
|         |         \--- com.google.android.gms:play-services-basement:17.0.0 (*)
|         +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|         +--- com.google.android.gms:play-services-iid:[17.0.0] -> 17.0.0
|         |    +--- androidx.collection:collection:1.0.0 (*)
|         |    +--- androidx.core:core:1.0.0 (*)
|         |    +--- com.google.android.gms:play-services-base:17.0.0 (*)
|         |    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|         |    +--- com.google.android.gms:play-services-stats:17.0.0
|         |    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|         |    |    \--- com.google.android.gms:play-services-basement:17.0.0 (*)
|         |    \--- com.google.android.gms:play-services-tasks:17.0.0 (*)
|         \--- com.google.android.gms:play-services-stats:17.0.0 (*)
+--- project :react-native-view-shot
|    +--- com.facebook.react:react-native:+ -> 0.59.9 (*)
|    \--- com.android.support:support-v4:27.+ -> 28.0.0 (*)
+--- project :react-native-svg
|    \--- com.facebook.react:react-native:+ -> 0.59.9 (*)
+--- project :react-native-wheel-picker-android
|    +--- com.android.support:appcompat-v7:28.0.0 (*)
|    +--- com.facebook.react:react-native:+ -> 0.59.9 (*)
|    \--- cn.aigestudio.wheelpicker:WheelPicker:1.1.2
+--- project :react-native-linear-gradient
+--- project :react-native-image-picker
|    \--- com.facebook.react:react-native:+ -> 0.59.9 (*)
+--- project :react-native-i18n
|    \--- com.facebook.react:react-native:+ -> 0.59.9 (*)
+--- com.android.support:appcompat-v7:28.0.0 (*)
+--- com.facebook.react:react-native:+ -> 0.59.9 (*)
\--- :dx-captcha-1.4.8

然后发现就是react-native-device-info 这个函数库引用了 Androidx
在这里插入图片描述
出错版本:"react-native-device-info": "^0.24.3"
修改到正确版本: "react-native-device-info": "^2.1.2"

然后,执行命令:
npm install && npm audit fix

更新到指定版本就好。
参考资料:
https://github.com/facebook/react-native/issues/25294
https://blog.csdn.net/sunny_1020/article/details/88556251

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值