Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Gradle issue upgrading to version 0.5.0 - Gradle Migrating From 0.8 to 0.9 - Also Android Studio upgrade to 0.8.1

After upgrade message states:

Failed to refresh Gradle project 'XXX' The project is using an unsupported version of the Android Gradle plug-in (0.8.3). Version 0.9.0 introduced incompatible changes in the build language. Please read the migration guide to learn how to update your project. 

Same kind of issue after upgrade to Android Studio to version >= 0.8.0

like image 464
Cedric Simon Avatar asked Mar 07 '14 14:03

Cedric Simon


People also ask

How do I upgrade Android Gradle to latest version?

Update Gradle For the best performance, you should use the latest possible version of both Gradle and the plugin. You can specify the Gradle version in either the File > Project Structure > Project menu in Android Studio, or update your Gradle version using the command line.


2 Answers

Android Studio 0.5.0 requires gradle-plugin 0.9.0

The gradle-plugin 0.9.0 works with Gradle 1.10 or Gradle 1.11

Modify your build.gradle script as suggested by Cedric.

There is a relation between gradle-plugin and the gradle version. For example

UPDATED TO 27/11/2015:

com.android.tools.build:gradle:0.6.+   -> gradle 1.8 com.android.tools.build:gradle:0.7.+   -> gradle 1.9 com.android.tools.build:gradle:0.8.+   -> gradle 1.9/1.10 com.android.tools.build:gradle:0.9.+   -> gradle 1.10/1.11 com.android.tools.build:gradle:0.10.+  -> gradle 1.10/1.11/1.12 com.android.tools.build:gradle:0.11.+  -> gradle 1.10/1.11/1.12 com.android.tools.build:gradle:0.12.+  -> gradle 1.10/1.11/1.12 com.android.tools.build:gradle:0.13.+  -> gradle 2.1 com.android.tools.build:gradle:0.14.+  -> gradle 2.1 com.android.tools.build:gradle:1.0.+   -> gradle 2.2.1-2.3 com.android.tools.build:gradle:1.1.+   -> gradle 2.2.1-2.3 com.android.tools.build:gradle:1.2.+   -> gradle 2.2.1+ com.android.tools.build:gradle:1.3.+   -> gradle 2.2.1+ com.android.tools.build:gradle:1.3.+   -> gradle 2.2.1+ com.android.tools.build:gradle:1.5.+   -> gradle 2.2.1+ com.android.tools.build:gradle:2.0.+   -> gradle 2.10.0+ 

You can find gradle version used in your project in the file gradle/wrapper/gradle-wrapper.properties

Also there is a relation between gradle-plugin and the IDE version.

Android Studio 0.3.x  -> gradle-plugin 0.6 Android Studio 0.4.x  -> gradle-plugin 0.7 Android Studio 0.4.3+ -> gradle-plugin 0.8 Android Studio 0.5.x  -> gradle-plugin 0.9 Android Studio 0.5.8  -> gradle-plugin 0.9.+ or 0.10.+ Android Studio 0.5.9  -> gradle-plugin 0.9.+ or 0.10.4+ Android Studio 0.6.x  -> gradle-plugin 0.11.+ Android Studio 0.8.x  -> gradle-plugin 0.12.+ Android Studio 0.8.11+  -> gradle-plugin 0.13.+ / gradle-plugin 0.12.+ Android Studio 0.9.x  -> gradle-plugin 0.14.+ Android Studio 1.0.0  -> gradle-plugin 1.0.0 Android Studio 1.1.x  -> gradle-plugin 1.0.0/ 1.1.x / 1.2.x Android Studio 1.2.x  -> gradle-plugin 1.0.0/ 1.1.x / 1.2.x Android Studio 1.3.x  -> gradle-plugin 1.0.0/ 1.1.x / 1.2.x / 1.3.x  Android Studio 1.4.x  -> gradle-plugin 1.0.0/ 1.1.x / 1.2.x / 1.3.x  Android Studio 1.5.x  -> gradle-plugin 1.0.0/ 1.1.x / 1.2.x / 1.3.x / 1.5.x Android Studio 2.0.x  -> gradle-plugin 2.0.0   Also gradle 1.12 requires Android Studio 0.5.8+ 

For updated news you can check this link: http://tools.android.com/recent
For updated doc about the gradle plugin check here.

If you change your plugin version, check compatibility, and then click sync project with your gradle files.It will download a new plugin version if you need it.

like image 51
Gabriele Mariotti Avatar answered Sep 19 '22 06:09

Gabriele Mariotti


To fix it, open file called build.gradle in the project root, and change gradle version there to 0.9.+.

buildscript {     repositories {         mavenCentral()     }     dependencies {         classpath 'com.android.tools.build:gradle:0.9.+'     } } 

To be repeated for each project ;(

If you then get a message like "Unable to load class 'org.gradle.api.artifacts.result.ResolvedComponentResult".

Go to you project_folder/gradle/wrapper directory and edit Unable to load class 'org.gradle.api.artifacts.result.ResolvedComponentResult'. file changing the distributionUrl to

distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip 

After upgrade to version 0.8.1 (full download and copy SDK folder over), had to have new version of gradle installed by IDE (using the "Fix it" link a couple of time :S ), and modifing the "android" section of the gradle file in project folder from 19.0 to 19.1, as below: buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.12.+' } } apply plugin: 'android'

repositories {     mavenCentral() }  android {     compileSdkVersion 19     buildToolsVersion '19.1.0'      defaultConfig {         minSdkVersion 7         targetSdkVersion 19     } }  dependencies {     compile 'com.android.support:appcompat-v7:19.1.+'     compile 'com.android.support:support-v4:19.1.0' } 
like image 20
Cedric Simon Avatar answered Sep 21 '22 06:09

Cedric Simon