android - 错误 : Unable to resolve dependency for ':react-native-maps@debug/compileClasspath' : Could not resolve androidx. appcompat :appcompat:1. 0.0

标签 android reactjs react-native gradle dependencies

我要做的就是在基本应用程序上安装 react 原生 map 。我不断收到构建的随机错误。我已经尝试了几个不同的 gradle 版本,但仍然没有运气。任何人都可以帮忙吗?

重新安装 react 原生 map
新鲜项目
更改 gradle 版本
更改 SDK 版本等
研究过。很多!

// app (build.gradle)

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules

    implementation(project(':react-native-maps')){
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    implementation 'com.google.android.gms:play-services-base:10.0.1'
    implementation 'com.google.android.gms:play-services-maps:10.0.1'

    // JSC from node_modules
    if (useIntlJsc) {
        implementation 'org.webkit:android-jsc-intl:+'
    } else {
        implementation 'org.webkit:android-jsc:+'
    }
}

// react-native-maps (build.gradle)

dependencies {
  compileOnly('com.facebook.react:react-native:+') {
    exclude group: 'com.android.support'
  }
  implementation "com.android.support:appcompat-v7:${safeExtGet('supportLibVersion', '28.0.0')}"
  implementation "com.google.android.gms:play-services-base:10.0.1"
  implementation "com.google.android.gms:play-services-maps:10.0.1"
  implementation 'com.google.maps.android:android-maps-utils:0.5'
}

ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.0.
Show Details
Affected Modules: react-native-maps


ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve androidx.core:core:1.0.0.
Show Details
Affected Modules: react-native-maps


ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve androidx.vectordrawable:vectordrawable:1.0.0.
Show Details
Affected Modules: react-native-maps


ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Show Details
Affected Modules: react-native-maps


ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.2.
Show Details
Affected Modules: react-native-maps


ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve androidx.core:core:1.0.1.
Show Details
Affected Modules: react-native-maps


ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve androidx.vectordrawable:vectordrawable:1.0.1.
Show Details
Affected Modules: react-native-maps


ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve androidx.core:core:1.0.0.
Show Details
Affected Modules: react-native-maps


ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve androidx.vectordrawable:vectordrawable:1.0.0.
Show Details
Affected Modules: react-native-maps


    WARNING: The specified Android SDK Build Tools version (26.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.3.0.
    Android SDK Build Tools 28.0.3 will be used.
    To suppress this warning, remove "buildToolsVersion '26.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
    Remove Build Tools version and sync project

最佳答案

这与 androidx 更新有关,除非您使用的是我认为今天发布的 React Native 0.60,否则您需要将您的 android 实现限制为需要 androidx 的 Google 之前的版本。

在我们的项目中,我们必须在 app/build.gradle 的底部添加以下内容:

configurations.all {
    resolutionStrategy.force 'com.google.android.gms:play-services-gcm:16.1.0', 'com.google.android.gms:play-services-basement:15.0.0'
}

我们的依赖项需要限制为:
implementation 'com.facebook.react:react-native:0.59.3'  // From node_modules    
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services-gcm:16.1.0'

我们还需要约束所有 :+依赖于特定版本,以确保这些依赖项没有发布不兼容的更新。因此,我们将我们的 react native 实现更新为我们当前使用的版本,此外,您需要研究您的 jsc 实现以找到与它们一起使用的正确版本。

万一这很重要,我们使用的是 gradle 3.3.1 和 SDK 28.0.3。

让我知道这是否还不够有意义。我们可能做的更多,但如果我没记错的话,这些就是我需要做的改变,以确保我没有使用 androidx。您可能还需要不同版本的 map 。

关于android - 错误 : Unable to resolve dependency for ':react-native-maps@debug/compileClasspath' : Could not resolve androidx. appcompat :appcompat:1. 0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56937704/

相关文章:

Android - proguard.cfg 错误

java - ConcurrentModificationException 使我的应用程序崩溃

ios - 如何使用本地podspec项目进行开发

android - 在 Android 中开发双向 Spinner

java - 类似sha512的php for android密码登录

reactjs - 好像有一个RN网络检查工具。在哪里?

javascript - 捕获传入路由并在登录后重定向回来

css - 滚动不工作 : react-grid-layout: 0-showcase example

node.js - 无法在Windows上npm安装react-native

android - react native 矢量图标显示为问号