0

Any clarification on this subject would be greatly appreciated. I know this has been answered many times but my current issue is that I don't know where or in what file (s) to add this to:

buildscript {
    repositories {
        ...
        google()     // <-- add this 
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

And this:

allprojects {
    repositories {
        jcenter()
        google()
    }
}

Or if that even solves my issue, since I haven't tested it yet.

My initial problem:

The issue seemed to appear after updating both gradle and Android studio. I'm currently working on a project using libGDX to make an Android app called CastleCrush. When I try to launch a desktop application to test it, it won't launch, and I get this error:

Error:Gradle: A problem occurred configuring root project 
    'CastleCrush'.
    > Could not resolve all files for configuration ':classpath'.
      > Could not find com.android.tools.build:gradle:3.0.1.
 Searched in the following locations:
     file:/Users/TrulsElg/.m2/repository/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
     file:/Users/TrulsElg/.m2/repository/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
     https://repo1.maven.org/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
     https://repo1.maven.org/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
     https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
     https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
     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
 Required by:
     project :

When launching with a virtual Android device it launches just fine. I'm not working on this project alone and collaboration is done via Git, if that makes any difference. None of the other project members seem to have this issue.

Bugs
  • 4,491
  • 9
  • 32
  • 41

2 Answers2

0

You add this to your Project build.gradle file. its the gradle file that is called build.gradle(Project: your project name). It is usually the first one if you are in the Android project view

Kunal Shah
  • 610
  • 6
  • 17
0

Could not find com.android.tools.build:gradle:3.0.1.

Gradle trying to find Android Gradle plugin version 3.0.1 artifact from your local maven repo (inside your computer) and from your listed three remote repository (maven2, oss.sonatype and jcenter).

But not succeeded because given artifact is not available on those repository.

Artifact com.android.tools.build:gradle:3.0.1 is available on google repository.

Find build.gradle file inside your libgdx project and add google maven repo inside allprojects tag

repositories {
        mavenLocal()
        mavenCentral()
        maven {                                  // <-- Add this
            url 'https://maven.google.com/' 
            name 'Google'
        }
    } 

If you're using Android Studio 3.0 or latter version

repositories {
      mavenLocal()
      mavenCentral()
      google()        //---> Add this
}

Abhishek Aryan
  • 19,936
  • 8
  • 46
  • 65