Android Studio (0.5.3) is driving me crazy.
I have never had any serious issues with Eclipse and ADT. Android Studio is another story: I have not been able to get a single project to build correctly with it.
So, I am trying to import an Android sample project (which I suppose has correct Gradle settings and should ready to be imported):
C:\pathToMyAndroidSDK\sdk\samples\android-19\content\StorageProvider
The first error I get is the following:
Failed to refresh Gradle project 'StorageProvider'
The project is using an unsupported version of Gradle. Please use version 1.10.
Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.)
Fix Gradle wrapper and re-import project Gradle settings
OK, so I download Gradle 1.10, and change the project Gradle settings, so that it uses this local Gradle distribution instead of the default gradle wrapper (which seems to be included in the sample project).
I get a different error this time:
Failed to refresh Gradle project 'StorageProvider'
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.
I don't know Gradle enough to migrate the configuration myself, and I don't really want to.
How can I simply use the gradle wrapper without gettting summoned to use Gradle 1.10 (which is not compatible with the project) ? Any other solution is also welcome.
Note: I have tried with other sample projects in the android-19 folder, only to get the same errors.
EDIT:
I have had more luck trying to build under Linux with the command line (gradlew build
).
The build succeeded, regardless of what I set in build.gradle
:
classpath 'com.android.tools.build:gradle:0.9.+'
or
classpath 'com.android.tools.build:gradle:0.8.+' #(the original configuration of the sample project)
So my problem seems to be caused by bugs in Android Studio.
Without knowing gradle, it is quite difficult to resolve this issue.
At the same time Android Studio is an alpha release, so it can change quickly, and each version can introduce incompatible changes
Here the first doc to read about a project with Android Studio: https://developer.android.com/sdk/installing/studio-build.html
You are using AS 0.5.3 so you have to use gradle 1.10/1.11 and the gradle plugin 0.9.x
It means that in your build.gradle script you have to use:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
May be in your file you have 0.8.3.
Also you have to use gradle 1.10/1.11. You should have a folder project_folder/gradle/wrapper where there is a file gradle-wrapper.properties.
Here you have to change the distributionUrl key to use one of these version:
distributionUrl=http://services.gradle.org/distributions/gradle-1.10-all.zip
Android Studio - Gradle - Gradle plugin have some relation:
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
May be your gradle script can have other issues after these changes.
The only thing which worked for me, was to change where Android Studio go searching for gradle files.
Using the gradle-wrapper.properties (auto-generated) from gradle 2.10 and above it's a lot easier
Don't forget to version control the gradle-wrapper.properties as suggested here: https://docs.gradle.org/current/userguide/gradle_wrapper.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With