首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >react本机-google和android.support.v4.net不存在错误

react本机-google和android.support.v4.net不存在错误
EN

Stack Overflow用户
提问于 2020-01-28 09:47:36
回答 1查看 288关注 0票数 2

在将react-native-google-signin集成到本地android代码时,我遇到了一些问题。我使用react本机0.59.8,到目前为止我还不能升级到0.60。因此,我遵循了较早的react-native-google-signin版本的说明,即2.1.1。不幸的是它对我不起作用。它给了我一些关于androidX的错误,但据我所知,react-native-google-signin从3.0.0以上开始使用androidX,但我使用的是2.1.1版本,不应该使用androidX。

描述

在Android中,这个问题在同步过程中开始,这会给我带来以下错误:

代码语言:javascript
复制
ERROR: Manifest merger failed : 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.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.

现在,当我试图在Android中构建我的项目时,它给了我另一个错误:

代码语言:javascript
复制
error: package android.support.v4.net does not exist

令人感兴趣的是,现在的问题涉及包@react-native-community/netinfo,它在我将react-native-google-signin链接到我的项目之前运行得很好。如果有人告诉我发生了什么,我会非常感激的。

编辑:

android/app/build.gradle中的依赖项部分如下所示:

代码语言:javascript
复制
dependencies {
    implementation project(':react-native-google-signin')
    implementation project(':react-native-reanimated')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-firebase')
    implementation project(':react-native-community-netinfo')
    implementation project(':react-native-orientation')
    implementation project(':react-native-keychain')
    implementation project(':react-native-view-shot')
    implementation project(':react-native-video')
    implementation project(':react-native-fs')
    implementation project(':react-native-blur')
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation 'com.facebook.react:react-native:+'
    implementation 'com.android.support:design:27.1.1'
    implementation project(':react-native-navigation')
    implementation 'com.google.android.gms:play-services-base:16.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation "com.google.firebase:firebase-messaging:17.5.0"
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-01-28 10:36:34

请试用以下方法:

打开/android/app/build.gradle文件,检查dependencies。搜索firebase的任何play服务实例,并查看以下两项内容:

  1. 行以实现开始(而不是编译)
  2. 查看其中是否有get latest Version通配符(即+-Sign)。(例子:implementation "com.google.android.gms:play-services-base:+"

(如果您没有发现用+__-符号实现的任何组件,请从这个答案中的“继续-这里”⇓继续下去。)

获取这些(在我的示例中是com.google.android.gms:play-services-base ),并在MVNRepository上搜索它,以获得可用版本的概述。

在这里,您可以选择最新的组件,或者通过这样的更新/android/app/build.gradle来选择使用您的应用程序的组件:

代码语言:javascript
复制
implementation ("com.google.android.gms:play-services-base:17.1.0"){ force = true }

(注:我不知道,如果你的例子是游戏服务基础,那只是一个例子)

⇒ON-HERE

之后,切换到/android并运行./gradlew :app:dependencies。这将为您的项目重新生成依赖树。

打开创建的文本文件,搜索更新后的Component:com.google.android.gms:play-services-base,查看组件将在何处使用。

您可能会发现,仍然有一些组件在依赖项中使用+-Sign (com.google.android.gms:play-services-base:+)。要解决您的问题,您需要修补它们(可能使用贴片包装简化此过程),也可以使用上面选择的组件的版本(在我们的示例“play-services-base”中)。

希望这能帮到你。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59945984

复制
相关文章

相似问题

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