【问题标题】:ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.0错误:无法解析“:react-native-maps@debug/compileClasspath”的依赖关系:无法解析androidx.appcompat:appcompat:1.0.0
【发布时间】:2019-07-08 15:01:38
【问题描述】:

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

重新安装 react 原生地图 新鲜项目 更改 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

【问题讨论】:

  • 您是否尝试重新启动 Metro bundler(重置缓存)并重新构建应用程序?你有没有关联依赖关系?
  • 感谢您的回复。我已经尝试了一切,尤其是那些步骤:(

标签: android reactjs react-native gradle dependencies


【解决方案1】:

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

在我们的项目中,我们必须在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。您可能还需要不同版本的地图。

【讨论】:

    【解决方案2】:

    gradle/wrapper/gradle.properties尝试设置:

    android.enableJetifier=false

    【讨论】:

      猜你喜欢
      • 2019-04-07
      • 1970-01-01
      • 2018-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多