Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the gradle version in Android studio 1.3?

I have updated to Android studio to version 1.3. In my project I need to use gradle version 2.2.1 and android gradle plugin version 1.0.0. How can I set android studio to use gradle version 2.2.1 automatically?

I have set the gradle wrapper-properities to 2.2.1 and in the project stucture it also shows it is using gradle version 2.2.1

gradle-wrapper.properties

#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle2.2.1-all.zip

Output:

Error:Gradle 2.4 requires Android Gradle plugin 1.2.0 (or newer) but project is using version 1.0.0. Please use Android Gradle plugin 1.2.0 or Fix plugin version and sync project

I want to use Gradle 2.2.1 but it keeps jumping to 2.4

like image 733
Fergal Fitz Avatar asked Aug 04 '15 15:08

Fergal Fitz


People also ask

Which Gradle version should I use for Android Studio?

If you've updated your Android Studio to 1.3. 2 version then I would suggest using Build Tools Version 23.0. 0 and compile API 23 Android 6.0. As for Gradle Version - 2.4 or higher up to latest 2.7.

Where is Gradle settings in Android Studio?

Open your project in Android Studio and select File > Settings... > Build, Execution, Deployment > Build Tools > Gradle (Android Studio > Preferences... > Build, Execution, Deployment > Build Tools > Gradle on a Mac).


3 Answers

I was getting the same error in Android Studio and it turns out that Android Studio was pointing to it's own version of gradle instead of my project gradle wrapper.

For Windows Android Studio, Go into File > Settings > "Build, Execution, Deployment" > "Build Tools" > Gradle and change it to "Use default gradle wrapper (recommended)".

This fixed it for me without having to change the dependencies. Hopefully, this is all you need.

like image 115
Mykaelos Avatar answered Sep 26 '22 07:09

Mykaelos


In your project's build.gradle (NOT your app's module) make sure that its using android gradle build tools of 1.2.0 or above. So in your file, the dependency section should look something like this:

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

If you always want the lastest gradle build tools, change it to:

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

From OP:

This dosnt solve my problem. I need to user plugin version 'com.android.tools.build:gradle:1.0.0' in my project, so i have set it to this in my project build.gradle file. The problem I have is that this worked with using gradle 2.2.1 but since android Studio 1.3 is using gradle 2.4 it is not working. So I need to somehow get android studio to use gradle version 2.2.1 so i can use gradle plugin 1.0.0 .

like image 43
Sree Avatar answered Sep 26 '22 07:09

Sree


It is recommended to use latest Gradle thats why Android Studio warns to upgrade it to the newest version.

Why you want to switch back to the older version?

Note: If you are thinking the newer version will create any complication in your stable code, they be assured that it will not cause any harm to you code. And you can't attain any extra benefit from the older version. Newer version means more efficient and bug free thing.

like image 26
Mohammad Arman Avatar answered Sep 26 '22 07:09

Mohammad Arman