首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在react-native或ExpoKit中,Android Material和appcompat清单合并失败

在react-native或ExpoKit中,Android Material和appcompat清单合并失败
EN

Stack Overflow用户
提问于 2019-06-18 13:40:30
回答 13查看 10.7K关注 0票数 36

我将'android.support:appcompat-v7‘更新为28.0.0

但它带来了构建过程中的错误。

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:8:5-23:19 to override.

然后我在我的Logcat中得到这个错误:

清单合并失败

我的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'
}

我该如何修复它?

我需要你的解决方案。

提前谢谢你。

EN

回答 13

Stack Overflow用户

回答已采纳

发布于 2019-06-18 13:56:12

我通过搜索@MehulSolanki answer找到了一个解决方案。

我补充说

tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"

在我的AndroidManifest.xml

并更新com.android.tools.build:gradl:

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
  }

并将其添加到您的gradle.properties文件中

android.useAndroidX=true
android.enableJetifier=true

错误:标记无法解析变量'${animal.sniffer.version}‘

错误:标记无法解析变量'${junit.version}‘

如果出现上述错误

  1. 文件->无效缓存/重新启动
  2. Build ->清理项目

错误:包android.support.annotation不存在错误:找不到可为空的符号类

如果出现上述错误

添加implementation 'androidx.annotation:annotation:1.1.0'

更改import android.support.annotation.Nullable; => androidx.annotation.Nullable;

更改import android.support.annotation.NonNull; => androidx.annotation.NonNull;

编译版本目标版本应为28.

票数 6
EN

Stack Overflow用户

发布于 2019-06-18 18:12:16

'react-native-device-info'升级到version 2.1.2为我修复了这个错误。请参阅github.com/facebook/react-native/issues/25294#issuecomment-503024749

简而言之:该库使用"services-gcm:+"作为依赖项,而最新的gcm版本导致了这个问题。

票数 48
EN

Stack Overflow用户

发布于 2019-06-18 18:32:11

根本原因是迁移到Androidx,谷歌play服务更新到androidX感谢MR03web这个问题属于react-native-device-info?最佳选择是使用以下命令升级react-native-device-info

yarn upgrade react-native-device-info@2.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"
票数 13
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56642369

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档