android - 如何修复 react-native android 中的“清单合并失败”?
问题描述
清单合并失败:来自 [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 的属性 application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) 也存在于[androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory)。建议:将 'tools:replace="android:appComponentFactory"' 添加到 AndroidManifest.xml:11:5-60:19 的元素以覆盖。
这是在升级 react-native 版本之后
构建.gradle
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.rugbyvault"
minSdkVersion 16
targetSdkVersion 28
versionCode 16
versionName "1.0"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
}
dependencies {
implementation project(':tipsi-stripe')
implementation project(':react-native-splash-screen')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-keep-awake')
implementation project(':react-native-code-push')
implementation project(':react-native-sound')
implementation(project(':react-native-firebase')) {
transitive = false
}
implementation project(':react-native-svg')
implementation project(':instabug-reactnative')
implementation project(':react-native-picker')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'com.android.support:multidex:1.0.3'
//noinspection GradleCompatible
implementation "com.android.support:appcompat-v7:28.0.0"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.android.gms:play-services-base:17.0.0"
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.google.android.gms:play-services-wallet:17.0.0'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
}
解决方案
似乎最新版本的 react-native 使用了 AndroidX 库。因此,您需要将您的依赖项(在您的情况下:appcompat和multidex)升级到 AndroidX。
仅供参考:AndroidX ( androidx.* ) 是 android 支持库 ( com.android.support.* ) 的新捆绑包。
您应该替换以下行:
implementation 'com.android.support:multidex:1.0.3'
implementation "com.android.support:appcompat-v7:28.0.0"
有了这个:
implementation 'androidx.multidex:multidex::2.0.1'
implementation "androidx.appcompat:appcompat:1.0.2"
将这些标志放入您的
gradle.properties
可以解决一些相关问题:
android.enableJetifier=true
android.useAndroidX=true
推荐阅读
- sql - 如何加入两个查询,将“城市”作为第一列的过滤器
- python - 如何检查列表中是否包含列表列表?
- css - Angular 材质:Shake MatDialog
- python - 来自子建模的 Keras 模型无法编译
- c# - 比较两个 json 对象并返回另一个仅在 c# 中更改的 JSON 对象
- angular - 如何在 spec.ts 文件中模拟/伪造组件实例的 HTML 代码(ng 测试)
- jmeter - adopopenjdk 8 在 jmeter 中的问题
- excel - 循环:根据列表查找字符串并在另一张表中调整尾随零和边框周围
- php - 如何将 Doctrine Entity Manager 配置为公共 Symfony 服务?
- java - 当我有“无法扫描[...]”警告时,如何在我的 Spring Boot 应用程序中处理 JAR 扫描?