WVrock WVrock - 10 days ago 94
Java Question

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

A friend of mine copy pasted a libgdx project folder on his pc and sent the project to me(through google drive). We are both using Android Studio. I downloaded and imported the project and it is working properly on the emulator. However it is not working on the desktop. On his pc, it works both in desktop and in the emulator.

When I try to run it in the desktop, Android Studio gives me this error message:

Error:Gradle: A problem occurred configuring root project 'bouncerGDX - Copy'.

> Could not resolve all dependencies for configuration ':classpath'.

> Could not find com.android.tools.build:gradle:2.2.2.
Searched in the following locations:

https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.pom

https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.jar

https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.pom

https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.jar
Required by:
:bouncerGDX - Copy:unspecified


How can I fix this? I have no experience with Gradle.

Answer

UPD:

It seems can't resolve com.android.tools.build:gradle:2.2.2 dependency for the classpath.

For me, adding the jcenter to gradle.build resolves the issue:

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        jcenter()
}

or, alternatively, the line in grable.build

classpath 'com.android.tools.build:gradle:2.2.2'

can be changed to

classpath 'com.android.tools.build:gradle:2.1.3'

^^^ this version exist in repo1.maven.org

WRONG SUGGESTION:

Resolve all dependencies by running gradle task (can be done from Android Studio's terminal):

For Linux:

./gradlew buildDependents

For Windows:

gradlew.bat buildDependents

Also, this commands might also help later

Linux:

./gradlew cleanIdea idea

Windows:

gradlew.bat cleanIdea idea

This is the reference to libgdx How-to-setup-development-env instruction