在升级到RN 0.59.9之后,我正在尝试构建一个React Native Android应用程序,但我得到了一个与AndroidX相关的错误。
我尝试了很多方法,包括删除大多数本地包,更改AndroidManifest.xml和互联网上提到的各种其他解决方案,但似乎都不起作用。
我的错误是:
> Task :app:processReleaseManifest FAILED
....\android\app\src\main\AndroidManifest.xml:22:18-91 Error:
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:35:2-108:16 to override.
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
FAILURE: Build failed with an exception.
据我所知,这意味着其中一个包使用AndroidX,但不是主应用程序,然而,据我所知,我的应用程序中没有使用AndroidX,并且我确保升级到RN 0.59,而不是0.60。我甚至尝试过grep "androidx“并删除所有可能提到它的包。
我还尝试将"android.useAndroidX=true / android.enableJetifier=true“添加到gradle.properties中,只是想看看会发生什么,但正如预期的那样,许多模块没有构建,因为它们还没有升级到AndroidX。
你知道怎么修复这个bug吗?
发布于 2019-06-19 09:00:50
这很可能是因为安卓发布了所有的AndroidX库,以及‘+’风格的gradle依赖项泄漏。
你可以通过./gradlew :app:dependencies|grep androidx
找到有问题的库,然后使用gradle resolutionStrategies或android/build.gradle ext{}版本控制来固定Google库依赖,或者你可以将你的react原生项目转换成androidx,然后通过npm i jetifier && npx jetify
使用jetifier工具,这样非androidx的react原生库就可以工作了。
当react-native生态系统过渡到AndroidX时,这两种方法都应该能够正常工作
https://stackoverflow.com/questions/56653182
复制相似问题