Just updated Android-Studio to version 0.2.7 an now I get the error message from the title:
In the log window there is link to the grade setup:
No matter which option I use the error message stays the same.
I deleted my ~/.gradle
directory and projects **/.gradle
directories.
It seems that nothing helps.
Nitpick: compile on the command-line using \opt\gradle\1.6\bin\gradle.bat build
works fine.
I managed to fix my project through some combination of invalidating Android Studio cache, deleting .idea
and .gradle
directories and .iml
files, restarting Studio, and reimporting the project:
on Mac OSX using Homebrew, brew install gradle
then pick local gradle distribution and point to /usr/local/Cellar/gradle/1.7/libexec
for gradle home:
Answer:
- Go to Preferences > Project Settings > Gradle and choose “Use gradle wrapper” instead of the bundled option
- Open your
gradle-wrapper.properties
and change thedistributionUrl
to use 1.7 if it is not already (mine was 1.6), i.e.distributionUrl=http\://services.gradle.org/distributions/gradle-1.7-bin.zip
Answer:
You do not want to manage gradle at a system level, it is better handled per project. Android Studio projects already setup gradle wrapper handling when creating new projects but if you have an older one you can add the same file that Android Studio does. Think of this as an gradle bootstrap file that will download the correct gradle version per project. You can also read up on Gradle Wrapper and generate a shell script called gradlew that will provide gradle-free bootstrapping.
In gradle/wrapper/gradle-wrapper.properties
in your project directory make sure you have:
#
#Tue Oct 08 13:40:54 CEST 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.7-bin.zip
Then when you go into Gradle you can set it to use the gradle wrapper. This is the default when creating new projects in Android Studio.
There are at least three approaches to migration or adding Gradle properly and using the new project structure Google and Android Studio has introduced.
- Create a new project and copy over the code
- Export from Eclipse to Gradle (deprecated)
- Import code into Android Studio (recommended)
- Try to manually get everything in order by creating the correct gradle files and reorganizing the project.
For now I’m copying the files over to a new project until the tools get a bit better.
Answer:
We have two computers, one of which gave that same message after upgrading to Android Studio 0.2.7. We noticed that the computer which could still build had Gradle installed independently of Android Studio.
Installing Gradle 1.6 downloaded from the Gradle web site fixed this issue on the computer that wouldn’t build.
Answer:
My fix was basically what Abe did but I wanted to give a bit more explanation:
Download gradle 1.6 from the gradle website
Extract somewhere on your pc/mac
Open up android studio, go to Preferences -> Gradle (left panel) -> and chooose Local gradle distribution.
Point Gradle home to the location where you extracted gradle.
This fixed the issue for me. Using the gradle wrapper and the bundled gradle distribution both failed
Answer:
In my case, i updated gradle to the latest version (1.8) and then changed the gradle.build files (for my project and for the libraries i was using) like these:
dependencies {
classpath 'com.android.tools.build:gradle:0.6.1+'
}
The Synchronize files and Refresh/Invalidate cache. This seems to solve the problem. I think that Gradle in order to determine the minimum required version just reads the above value.
Answer:
Here’s what I did to get my project working:
- Installed Gradle 1.7 on my OS (OS X users can use brew for this)
- Added this to my
local.properties
file:sdk.dir=/Applications/Android\ Studio.app/sdk
- Created gradle wrappers with
gradle wrapper
command. - Chose “Use gradle wrapper (recommended)” option in Android Studio.
Tags: androidandroid