Could not find com.android.tools.build:gradle:4.1.3. after gradle upgrade in Android studio

Viewed 1863

After upgrading Android studio from 4.0.x to 4.1.3 for React native 0.64 app, I took the recommendation of upgrading gradle to 4.1.3 and followed the instruction to upgrade. However the React Native app rebuild throws an error:

Could not find com.android.tools.build:gradle:4.1.3.
Searched in the following locations:
  - https://jcenter.bintray.com/com/android/tools/build/gradle/4.1.3/gradle-4.1.3.pom

Clicking the above https://jcenter.binatray.com/com/... landed on page of Forbidden. Is it the cause of the error?

I also changed gradle version in gradle-wrapper.properties to 6.8.3 from 6.7:

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

Also in build.gradle, there is:

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

        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
        maven { url 'https://maven.google.com'
                name 'Google'
        } 
    }

Sync project throws the same error.

Update: build.gradle

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

buildscript {
    ext {
        buildToolsVersion = "29.0.3"
        minSdkVersion = 21
        compileSdkVersion = 29
        targetSdkVersion = 29
        ndkVersion = "20.1.5948944"
    }
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:4.1.3')
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

        jcenter()
        maven { url 'https://www.jitpack.io' }
        maven { url 'https://maven.google.com' } //for react-native-image-crop-picker
        mavenCentral()
    }
}
0 Answers
Related