Mike Walker
Mike Walker

Reputation: 3166

Android Studio Gradle Update

I'm attempting to update my gradle version within Android Studio. I am attempting to use version 2.10, but am running into issues.

Within my gradle-wrappers.properties I have

distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

Inside my build.gradle file for my project I have

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.10'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Within my Android Studio preferences, I do have Use default gradle wrapper selected. The errors I'm getting

4:04:01 PM Gradle sync failed: Could not find com.android.tools.build:gradle:2.10.
           Searched in the following locations:
           file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/android/tools/build/gradle/2.10/gradle-2.10.pom
           file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/android/tools/build/gradle/2.10/gradle-2.10.jar
           https://jcenter.bintray.com/com/android/tools/build/gradle/2.10/gradle-2.10.pom
           https://jcenter.bintray.com/com/android/tools/build/gradle/2.10/gradle-2.10.jar
           Required by:
           :MyApp:unspecified
           Consult IDE log for more details (Help | Show Log)

I can see it's trying to find two files: gradle-2.10.pom and gradle-2.10.jar. Am I supposed to install those files manually?

Upvotes: 0

Views: 828

Answers (2)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363439

Don't confuse the gradle plugin for android with the gradle version.

With this line you are declaring the gradle plugin. Use

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

The gradle version is defined in gradle/wrapper/gradle-wrapper.properties. Use:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

Upvotes: 2

Mattia Maestrini
Mattia Maestrini

Reputation: 32770

To update the gradle wrapper you don't need to change the version of Android Plugin for Gradle.

The last version of com.android.tools.build:gradle is 2.0.0. Change your build.gradle like this:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Upvotes: 1

Related Questions