4

When trying to Sync Gradle I am getting the following error:

A problem occurred configuring project ':react-native-google-signin'.
> Could not resolve all artifacts for configuration ':react-native-google-signin:classpath'.
   > Could not find com.android.tools.build:gradle:3.6.3.
     Searched in the following locations:
       - https://jcenter.bintray.com/com/android/tools/build/gradle/3.6.3/gradle-3.6.3.pom
       - https://jcenter.bintray.com/com/android/tools/build/gradle/3.6.3/gradle-3.6.3.jar
     Required by:
         project :react-native-google-signin

I have had a search and I am unable to find an answer to this. A similar question here: React native android can not find com.android.tools.build:gradle:3.6.3

Looking at the above this suggests switching off Offline mode, which is not on, so, unfortunately, that is not the answer.

The root bundle.gradle file looks like this:

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

buildscript {
  ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0-alpha1"
      reactNativeVersion = "0.59.9"
    googlePlayServicesAuthVersion = "16.0.1"
  }
    repositories {
        google()
        maven {
          url 'https://maven.google.com/'
        }
        jcenter()
        mavenCentral()
        maven {
            url 'https://maven.fabric.io/public'
        }
        maven { url 'https://dl.bintray.com/android/android-tools' }

      maven {url "$projectDir/../node_modules/react-native/android"}
    }
    dependencies {
        classpath('com.android.tools.build:gradle:3.4.1')
        classpath 'com.google.gms:google-services:4.1.0'
        classpath 'io.fabric.tools:gradle:1.25.4'
        // 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"
        }
        // React native video - exoplayer missing from google repos, temp fix
        maven {
            url "https://google.bintray.com/exoplayer/"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        jcenter()
//        configurations.all {
//            resolutionStrategy {
//                force 'com.facebook.android:facebook-android-sdk:4.28.0'
//            }
//        }
    }
}

Based on the error it seems it only searches in jcenter and not the others? I am not sure, but when I searched online this specific build is available from maven.google.com which is included?

StuartM
  • 6,743
  • 18
  • 84
  • 160

5 Answers5

1

Replace your android/build.gradle with this i.e in your project level gradle with this

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {url "https://maven.google.com"} //<---- this should be added and should be aboce jcenter
        maven {url "$rootDir/../node_modules/react-native/android"}
        jcenter()
    }
}

After that clear your gradle inside android/

gradlew clean

Then run the react native application.

NOTE: Use your own gradle and google service versions in above snippet

rkkkk
  • 123
  • 1
  • 9
  • I've edited the question and included the whole build.gradle file. Should the same changes still be needed, it seems the right parts are in the correct places? – StuartM May 08 '20 at 13:34
  • Hey, I had faced this issue before so I copy-pasted my final code :P. You can try the code as mentioned in the snippet and give it a try. – rkkkk May 08 '20 at 14:12
1

You should move to Androidx

AndroidX is a major improvement to the original Android Support Library, which is no longer maintained. You can migrate an existing project to AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.

Upgrade

    classpath 'com.android.tools.build:gradle:3.6.3'
    classpath 'com.google.gms:google-services:4.3.2'

And

    buildToolsVersion = "29.0.2"
    minSdkVersion = 16
    compileSdkVersion = 29
    targetSdkVersion = 29
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
0

You should try doing:

react native link
double-beep
  • 5,031
  • 17
  • 33
  • 41
Pratik Mittal
  • 163
  • 2
  • 7
0

I got this error after enabling flutter web which automatically upgraded my gradle file, so firstly disable your flutter web and update your compileSdkVersion and targetSdkVersion to the last version which is up to now 30

0

After spending 2 days finally resolved this issue, actually What I was doing that

maven { url 'https://jitpack.io' }

this line added in both repositories section , So remove the line you added in repositories section inside buildScript.

in build.gradle (project module)

buildscript {
    ext.kotlin_version = "1.4.31"
    repositories {
        google()
        jcenter()
        gradlePluginPortal()
    }
    dependencies {
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0"
        classpath "com.android.tools.build:gradle:7.0.2"
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
    }
}
allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

don't add maven at above repositories section , do like save above code. hope your problem resolved