Environment : Android Studio 2.1
Project : Android SDK + Cordova
Android Studio throws the following error during Gradle Sync :
Gradle sync failed:
Faced the same issue after upgrading to android studio 2.1 from 1.5
Managed to resolve by updating the dependencies version if the gradle.gradleVersion >= 2.1 in the build.gradle file under buildscript {}
OLD Configuration
if (gradle.gradleVersion >= "2.2") {
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
} else if (gradle.gradleVersion >= "2.1") {
dependencies {
classpath 'com.android.tools.build:gradle:0.14.0+'
}
} else {
dependencies {
classpath 'com.android.tools.build:gradle:0.12.0+'
}
}
Updated Configuration
if (gradle.gradleVersion >= "2.2") {
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
} else if (gradle.gradleVersion >= "2.1") {
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
} else {
dependencies {
classpath 'com.android.tools.build:gradle:0.12.0+'
}
}
If you do not have if/else clause in your build.gradle you can update the dependencies directly as below,
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}