Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native FAILURE: Build failed with an exception. Could not resolve ':classpath'. Could not find com.android.tools.build:gradle:3.0.1

When I make the command "react-native run-android" then it happened:

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring root project 'AsomeProject'.

    Could not resolve all files for configuration ':classpath'. Could not find com.android.tools.build:gradle:3.0.1. Searched in the following locations: https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle -3.0.1.pom https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle -3.0.1.jar

screenshot:

enter image description here

like image 784
MD Habibur rahman Avatar asked Nov 23 '17 12:11

MD Habibur rahman


4 Answers

I added google() and mavenlocal() to the buildscript

buildscript {
    repositories {
        google()
        mavenLocal()
        jcenter()
    }
    ....
}
like image 103
Alejandro Vargas Avatar answered Nov 19 '22 12:11

Alejandro Vargas


buildscript {
    repositories {
        google() // I had to put this before jcenter(). If I put jcenter() first it fails when running react-native run-android
        jcenter()
    }
}

To be clear though, if i put jcenter() first in buildscript, I could still get a successful build within Android Studio. Running react-native run-android however was failing until I put google() in front of jcenter(). After that everything was smooth as butter.

like image 27
ChrisF582 Avatar answered Oct 03 '22 11:10

ChrisF582


I had the same problem, I tried Manoj Prabhakar's solution but I fixed adding the google() repository to the buildscript block in the project level build.gradle

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}
like image 28
Roberto Martucci Avatar answered Nov 19 '22 14:11

Roberto Martucci


Jcenter does not have Gradle 3.0.1.

Gradle 3.0.1

It is available in Google's maven repository. here

You should add google() to allprojects in your project level build.gradle

Do this:

In your react native project, Navigate to -> android -> build.gradle.

add google() to allproject repository like this:

enter image description here

This should fix your problem.

Edit 1: replace google() with this

maven {
            url "https://maven.google.com/"
}  
like image 6
Manoj Prabhakar Avatar answered Nov 19 '22 12:11

Manoj Prabhakar