反应原生或ExpoKit中的Android Material和appcompat Manifest合并失败
react-native react-native-android (6)
我将'android.support:appcompat-v7'更新为
28.0.0
。
但它带来了构建错误。
Attribute [email protected] 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:8:5-23:19 to override.
然后我在Logcat中收到此错误:
Manifest merger failed
我的app.gradle:
configurations.all {
resolutionStrategy.force 'com.android.support:design:28.0.0'
resolutionStrategy.force "com.android.support:support-v4:28.0.0"
resolutionStrategy.force "com.android.support:support-media-compat:28.0.0"
}
...
dependencies {
implementation 'com.android.support:multidex:1.0.1'
// Our dependencies
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
}
我如何解决它?
我需要你的解决方案。
先感谢您。
-
尝试升级到AndroidX( Instruction ),然后运行
npm update
。 如果某些插件损坏,请丢弃先前的更改并转到第二步。 -
降级Google Play服务版本。 在
android/app/build.gradle
更改
compile 'com.google.android.gms:play-services-<service_name>:+'
至
compile 'com.google.android.gms:play-services-<service_name>:16.0.0'
所以在我的情况下,
<sevice_name>
是
location
。
但在其他人的情况下,它可能是任何其他Google Play服务(如此处列表
http://www.androiddocs.com/google/play-services/setup.html
)。
所以它解决了,但第二步 - 是一个临时修复,直到一些RN插件将更新到AndroidX。
在
<application>
标签内的
AndroidManifest.xml
添加
'tools:replace="android:appComponentFactory"'
你的
AmdroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="ru.chopcode.myapplication">
<application
tools:replace="android:appComponentFactory"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
</application>
将
'react-native-device-info'
升级到
version 2.1.2
为我修复了错误。
见
github.com/facebook/react-native/issues/25294#issuecomment-503024749
简而言之:库使用
"services-gcm:+"
作为依赖项,最新的gcm版本导致了这个问题。
将以下内容添加到gradle.properties,然后清理/重建
googlePlayServicesVersion=16.1.0
firebaseVersion=17.6.0
根据
@Frank's
回答,库使用了
services-gcm:+
作为依赖项,最新的gcm版本导致了这个问题。
我曾在我的项目中使用过
:react-native-admob
。
所以我只是在
android/app/build.gradle
更改以下行
从:
implementation project(':react-native-admob')
至 :
implementation(project(":react-native-admob"), {
exclude group: "com.google.android.gms"
})
implementation "com.google.android.gms:play-services-ads:16.0.0"
根本原因是相关迁移到
Androidx
,谷歌播放服务更新到androidX感谢
MR03web
这个问题属于react-native-device-info?
最好的选择是使用升级
react-native-device-info
yarn upgrade react-native-device-[email protected].1.2
cd android && gradlew clean
react-native run-android
或者如果您不想升级,则应从
react-native-device-info
排除
com.google.android.gms
。
谢谢
implementation(project(":react-native-device-info"), {
exclude group: "com.google.android.gms"
})
implementation "com.google.android.gms:play-services-gcm:16.0.0"