React Native : Could not find com.android.tools.build:gradle:2.2.3

回眸只為那壹抹淺笑 提交于 2019-12-01 15:53:37

It seems com.android.tools.build:gradle:2.2.3 was removed from the jcenter repository.

Try adding this code to your top-level build.gradle file:

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

As seen the workaround from google issuetracker: https://issuetracker.google.com/issues/120759347#comment44

Seeing your error logs:

  • 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.

You are still searching for AGP 2.2.3 for your project :react-native-fetch-blob.

For those React Native or CordovaLib projects that are with Android Gradle Plugin lower versions, e.g. 2.2.3, you can try to replace the google() with below maven style, and add the android tools workaround. So, modify your top-level build.gradle file as below for both buildscripts and allprojects:

buildscripts {
    repositories {

        // below is the workaround for android tools 
        maven {
            artifactUrls "https://dl.bintray.com/android/android-tools/"
            url "https://jcenter.bintray.com"
        }
        maven {
            url "https://maven.google.com"
        }

        // ... 
        jcenter()

    }
}

allprojects {
    repositories {

        // below is the workaround for android tools 
        maven {
            artifactUrls "https://dl.bintray.com/android/android-tools/"
            url "https://jcenter.bintray.com"
        }
        maven {
            url "https://maven.google.com"
        }

        // ... 
        jcenter()

    }
}

Clean up your project and then perform a new Sync.

  • Try "File"->"Invalidate Caches / Restart ..."
  • Try to clean up your .gradle and .idea directory under your project root directory.

See below references:


For the warnings:

WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.

Because you are using AGP (Android Gradle Plugin 3.2.1), the build configuration compile has changed to implementation and api. Just replace all the compile with implementation or api will let this warning disappear. See: https://developer.android.com/studio/build/dependencies#dependency_configurations for more details.

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.

This warning is just for your information, you can simply ignore it or remove buildToolsVersion '25.0.2' from your build.gradle file to suppress this warning.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!