android - react native : Could not find com. android.tools.build :gradle:2. 2.3

标签 android react-native gradle build.gradle gradlew

我正在使用 react native 制作一个 android 应用程序,这是我遇到的错误:


    FAILURE: Build failed with an exception.

    * What went wrong:
    A problem occurred configuring project ':react-native-fetch-blob'.
    > Could not resolve all artifacts for configuration ':react-native-fetch-blob:classpath'.
       > Could not find com.android.tools.build:gradle:2.2.3.
         Searched in the following locations:
             https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
             https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar
         Required by:
             project :react-native-fetch-blob

我也收到以下警告:


    > Configure project :app 
    WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
    It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
    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.2.1.
    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.
    registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
    registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

    > Configure project :react-native-android-location-services-dialog-box 
    WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
    It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
    WARNING: The specified Android SDK Build Tools version (25.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.2.1.
    Android SDK Build Tools 28.0.3 will be used.
    To suppress this warning, remove "buildToolsVersion '25.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

这是我的 build.gradle 文件:


    // Top-level build file where you can add configuration options common to all sub-projects/modules.

    buildscript {
        repositories {
            google()
            jcenter()
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.1'

            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
            classpath 'com.google.gms:google-services:3.0.0'
        }
    }

    allprojects {
        repositories {
            google()
            mavenLocal()
            jcenter()
            maven {
                // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
                url "$rootDir/../node_modules/react-native/android"
            }

            // jitpack repo is necessary to fetch ucrop dependency
            maven { url "https://jitpack.io" }
        }
    }

这是我的 gradle wrapper 分发 url:

distributionUrl=https://services.gradle.org/distributions/gradle-4.6-all.zip

我尝试更改不同存储库的顺序,但仍然出现相同的错误。

最佳答案

com.android.tools.build:gradle:2.2.3 似乎已从 jcenter 存储库中删除。

尝试将此代码添加到您的顶级 build.gradle 文件中:

subprojects {project ->
    if (project.name.contains('react-native-fetch-blob')) {
        buildscript {
            repositories {
                maven { url "https://dl.bintray.com/android/android-tools/"  }
            }    
        }
    }
}

关于android - react native : Could not find com. android.tools.build :gradle:2. 2.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53713098/

相关文章:

android - 自定义 ListView 适配器行选择

javascript - React-Native:for 循环中的 this.something.map 可以访问 .json 文件中数据数组中的数据..有人可以建议一个示例代码吗?

android - React-native 没有更新 android 中的更改

android - 如何在 Windows 上运行 React Native 官方示例的 packager?

从 5.1.1 升级到 6.4.1 后,gradle 不获取依赖项

android - 启动应用程序时如何启动多个 fragment

android - 从 android studio 中的 gradle 路径中删除文件/jar/类

安卓 NDK- 错误 :Execution failed for task ':app:buildNative'

java - 从一组坐标和距离计算新的 GPS 坐标?

gradle - 是否可以设置 Gradle 任务依赖项来排除任务?