I am trying to build an android project from the command line.
I am following this tutorial
My project structure and files match the tutorial exactly.
When I run gradle build it tells me that version 2.2 of gradle is required, but I have a newer version of gradle installed, 2.10. So does that mean I must download an older version of gradle to build android?
* What went wrong:
A problem occurred evaluating root project 'GradleJavaApp'.
> Failed to apply plugin [id 'com.android.application']
> Gradle version 2.2 is required. Current version is 2.10. If using the gradle wrapper, try editing the distributionUrl in H:\GradleJavaApp\gradle\wrapper\gradle-wrapper.properties to gradle-2.2-all.zip
Don't use older version of Gradle! Stick to version 2.10 (or newer).
If you followed the tutorial thoroughly,
you probably used version 1.1.3 of Android build plugin:
buildscript {
…
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
}
}
Build plugin version 1.1.3 is terribly outdated from the view of Android development (released on March 2015 according to the release notes).
Change that to the latest version 2.1.0.
Gradle wrapper should then stop complaining about Gradle version and
you should be able to use Gradle 2.10 normally.
Also replace all mentions of Gradle 2.3 in the tutorial with version 2.10.
Related
I had a three year old Android Studio which I just upgraded to the latest version(3.2).
I opened a project and tried to run it, but I got this error:
Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly.
Then, I saw this in gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip
From what I understand Gradle 2.2 is not compatible with Android Studio 3.2.
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
Now however, if I try building again, I get this error:
Gradle version 2.2 is required. Current version is 4.9.
Why does it ask me for an old version of Gradle?
There are TWO places to be aware of:
Android Gradle Plugin version.
Android wrapper version and Gradle version
Each version of Android Gradle Plugin version requires a minimum version of gradle version. For your case, it looks these two versions are not in sync. So, try to modify your files as below:
Top level build.gradle
buildscript {
repositories {
...
}
dependencies {
// This is the Android Gradle Plugin version
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
Android studio doesn't support that version unfortunately. My advice is using 4.4, that's last full supported version.
My android-studio version is the latest 2.1.3,and I am try to update gradle to gradle-3.0-all with plugin 2.2.0-beta3.
When I build it was ok but when run the ide report that "Incompatible version of android studio with the Gradle version used."
How can I resolve this?Should I use android-studio 2.2+?
Just use the latest stable version of the gradle distribution and the gradle plugin for android:
In build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
}
In gradle/wrapper/gradle-wrapper.properties:
distributionUrl = https\://services.gradle.org/distributions/gradle-2.14-all.zip
Currently the version of gradle 3.x is not officially supported.
Android studio will notify you if Gradle plugin needs update. no need for doing it yourself.
I found a table here http://tools.android.com/tech-docs/new-build-system/version-compatibility but it has no entry for gradle 2.14. I am trying to build an app without an IDE with gradle
but it has no entry for gradle 2.14
Do not use Gradle 2.14. Use Gradle 2.14.1. If Gradle issues a patch level release, that's probably due to a critical bug.
Then, you are covered by the last row in the table, simulated below because Stack Overflow does not like teh tabelz:
Android Gradle Plugin Requires Gradle
2.1.3+ 2.14.1+
So, if you want to use Gradle 2.14.1, use version 2.1.3 or higher of the Android Plugin for Gradle.
I'm trying to build an Android project but the following error occurred
Error:(10, 1) A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> Gradle version 2.8 is required. Current version is 2.4. If using the gradle wrapper, try editing the distributionUrl in C:\Users\...\gradle\wrapper\gradle-wrapper.properties to gradle-2.8-all.zip
It seem something's wrong with the Gradle version, however I checked the gradle-wrapper-property and it's already 2.10.
Also in File-Project Structure-Project, gradle-version is also 2.10
No idea how this happened, I've also restarted android-studio many times.
For those that still need help, an answer on another post did it for me link.
You need to change Settings > Builds,Execution,Deployment > Build Tools > Gradle >Gradle home path
Or set Use default gradle wrapper and edit Project\gradle\wrapper\gradle-wrapper.properties files field distributionUrl like this
distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
I don't think that changing Gradle tools to version 1.5.0 is necessary, but if you're using 2.0-snapshot or beta version of gradle, I recommend you to change it to 1.5.0.
This error:
Error:(10, 1) A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> Gradle version 2.8 is required. Current version is 2.4. If using the gradle wrapper, try editing the distributionUrl in
C:\Users...\gradle\wrapper\gradle-wrapper.properties to
gradle-2.8-all.zip
only tells you that your project's Gradle system is a bit outdated and need to be updated to newer version.
Open your project Android Studio and in navigator on the left find file called gradle-wrapper.properties. It should have a content like this:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
Change the last line with distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
It should work.
Go To Android Preference and Just change Project level Settings to Use default gradle wrapper (recommended).
There is a bug in version checking in older android plugins. To fix this you can either go back to gradle 2.9 or use the newer plugin
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
But I see from your error message that it tries to run with gradle 2.4 so this is maybe another problem.
Updating the version of android studio from 1.4 to 1.5.1 fixed this problem for me.
I'm trying to execute gradle wrapper for an Android project, and this error is raised:
A problem occurred evaluating root project 'myapp'.
> Gradle version 1.10 is required. Current version is 1.12. If using the gradle wrapper, try editing the distributionUrl in /Users/dude/myapp/gradle/wrapper/gradle-wrapper.properties to gradle-1.10-all.zip
My wrapper task in build.gradle looks like this:
task wrapper(type: Wrapper) {
gradleVersion = "1.12"
}
I recently updated to Gradle v1.12 via Homebrew. Is it not supported or something? If so, where can I check this sort of thing?
A particular version of the Gradle Android plugin requires a particular version of Gradle (at least for now), and it seems that your version of the Gradle Android plugin requires Gradle 1.10. You might find more information on this in the documentation for the Gradle Android plugin.
PS: The wrapper task above creates the files necessary to run Gradle with the (generated) gradlew script, which is the preferred way to run Gradle (no manual install, every build can specify in its gradle-wrapper.properties which Gradle version it needs).
The version of Android gradle plugin needs to be compatible with the version of Gradle. Checkout the version compatibility mapping table here:
http://tools.android.com/tech-docs/new-build-system/version-compatibility
I had the same problem. It turned out that the old Android Studio created gradle related files one level above my application folder. In my case, the path was in ~/git/, and my project was at ~/git/myproject. I used Android Studio RC2 now, and no matter how I changed the config within the project, gradle still wanted to use the old 1.10 version. Therefore, I re-checked out the project a new path, and updated the gradle version reference within the project, then it compiled.