Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 444
WVrock Avatar asked Nov 27 '16 08:11

WVrock


3 Answers

UPD:

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

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

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

or, alternatively, the line in build.gradle

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

like image 93
exenza Avatar answered Nov 05 '22 14:11

exenza


I was getting the same issue after updating Android Studio 2.2.2 to 2.3.1

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

Solution:

Open the gradle location and make changes in build.gradle accordingly(module and project both)

I replaced

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

with

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

And gradle build successfully :-)

gradle location

like image 29
Jyoti Prakash Rai Avatar answered Nov 05 '22 13:11

Jyoti Prakash Rai


buildscript {
repositories {
    jcenter()
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
}
}

add google() below jcenter(),this works for me

like image 1
Glendian Avatar answered Nov 05 '22 14:11

Glendian