android - 尝试构建 React Native 0.59 应用程序时与 AndroidX 相关的 AndroidManifest 错误
问题描述
我正在尝试在升级到 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。
知道如何修复这个错误吗?
解决方案
这很可能是由于 Android 发布了所有 AndroidX 库,并且 '+' 样式的 gradle 依赖项泄漏。
您可以./gradlew :app:dependencies|grep androidx
找到问题库,然后使用 gradle resolutionStrategies 或 android/build.gradle ext{} 版本控制来固定 Google 库依赖项,或者您可以将您的 react-native 项目转换为 androidx 并使用 jetifier 工具,npm i jetifier && npx jetify
这样非-androidx react-native 库工作。
随着 react-native 生态系统过渡到 AndroidX
推荐阅读
- android - 当我尝试注册用户时出现错误
- c++ - 任何使用的理由!在 C++ 中?
- php - 当值不为空时从另一个表调用值
- c - 获取当前 X11 服务器时间
- java - IntelliJ IDEA 不显示新创建的类或文件。要查看文件,我需要完全重新启动程序
- python - 即使我导入了我的 python 文件也无法识别我的 sqlite 表
- laravel - Laravel Eloquent - 按数组顺序按列排序集合
- html - 悬停在各个链接上时如何设置“下划线”
- python - 如何跟踪和显示同一级别的访问节点?
- vue.js - 使用 vuejs 和 fetch() 在 Promise 调用中显示数据