So, like an idiot, I upgraded Android Studio.
And my project immediately stopped building because of gradle errors.
It says
12:06 Gradle sync started with single-variant sync
12:06 Gradle sync failed: Minimum supported Gradle version is 5.4.1. Current version is 5.1.1. If using the gradle wrapper, try editing the distributionUrl in /home/phil/Documents/PATH-TO-PROJECT/gradle/wrapper/gradle-wrapper.properties to gradle-5.4.1-all.zip (245 ms)
12:06 NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version=20.0.5594570
So I look in gradle-wrapper.properties and it does indeed say
#Wed Oct 30 11:57:04 BRT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
So the error message, if I'm interpreting it correctly says "change the gradle-wrapper.properties to refer to gradle-5.4.1" and, indeed, that's what the gradle-wrapper.properties DO refer to.
So I'm guessing this is an ambiguous error message or I'm just being stupid reading it.
Maybe although the error message is telling me to change TO 5.4.1, what it should really be telling me is either
a) upgrade my gradle to 5.4.1 because it's currently only 5.1.1.
If so, where do I do this? I never installed gradle myself. I just got it as part of the Android Studio bundle. So where in that Android Studio download can I do this?
or maybe
b) Android Studio automatically updated my gradle-wrapper.properties to 5.4.1, but really I need to change that properties file BACK to 5.1.1 because that's what I have installed.
How should I interpret and understand this problem?
I'm not really looking for a "magic spell" of "change these things" or "I cleaned my project and it worked for me".
I'm looking for a short but comprehensive explanation as to why these gradle incompatibility problems keep happening in Android Studio. So that I can understand what's actually going on and how to solve these things myself.
Update the Gradle version in gradle-wrapper.properties to5.4.1 and let it download that version. It doesn't matter what is globally installed, when using the wrapper (which fetches whatever is being requested). This is happening because the current build-tools plug-in (which has the same version as Android Studio) depends on Gradle >= 5.4.1. In directory ~/.gradle one often can remove old wrapper installations; keeping all projects at the same Grade version requires the least space on disk (since it keeps all Gradle versions ever built with, per user).
Alternatively, you could install Gradle >= 5.4.1 globally, eg. /opt/gradle/5.4.1 and remove the wrapper - but when being the only user on a computer, this is of no real advance, because manual updating is required.
I just updated Gradle and got a similar error.
In gradle-wrapper.properties, I changed
distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-all.zip
to
distributionUrl=https://services.gradle.org/distributions/gradle-5.1.1-all.zip
tried to build, then changed it back again, and it built.
Related
Today, multiple developers on my team started seeing this error when they attempt to run any Gradle task.
* Where:
Build file 'C:\dev\src\my_app_name\app\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> Minimum supported Gradle version is 4.4. Current version is 4.1. If using the gradle wrapper, try editing the distributionUrl in C:\dev\src\my_app_name\gradle\wrapper\gradle-wrapper.properties to gradle-4.4-all.zip
Absolutely no code or config changes were made; Gradle builds just suddenly started to fail. Anyone know why this would happen? My best guess is that a plugin with a dependency on a specific version of Gradle auto-updated itself, but I'm not sure how to figure out which one it is. The line number would suggest that it was the com.application.plugin plugin itself.
I am aware that Android Studio updates often require a corresponding upgrade to Gradle, but nobody on my team updated Android Studio. And, according to the Android-Studio-Gradle version compatibility table, Gradle 4.1 should still work fine with Android Studio 3.0.1, which is what I have been running for some time.
We recently started using Kotlin, and I thought that might be part of the problem, but completely removing everything related to Kotlin didn't help.
I have tried deleting the Gradle caches/ directory, running ./gradlew cleanBuildCache, deleting our project's build/ directories, killing Gradle daemons via ./gradlew --stop, and rebooting -- all to no avail.
I also tried upgrading to Gradle 4.4, but that resulted in a "CIRCULAR REFERENCE" NullPointerException error during DexMergerTransform (separate issue), for reasons that are entirely unclear to me. I'd like to be able to force my environment to NOT take on a Gradle 4.4 dependency right now... but I don't know what suddenly triggered this dependency.
The problem turned out to be that we were using a non-specific version of a plugin. When a change was made to the plugin, the new version was downloaded to our dev environments, and it introduced a dependency on a version of Gradle higher than the one we were using.
In our case, this was the culprit:
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT'
Downgrading to version 8.5.1 of the Butterknife plugin eliminated the dependency on Gradle 4.4.
You also have the option of linking to a specific pre-release "nightly" version. However, this is less than ideal, since these bits don't remain available for long, and you might want to download a build and keep it in your local lib. For example:
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-20180727.012508-40'
instead of down-grading, one could provide the plugin in version 9.0.0 with the expect version of Gradle, by editing the file gradle/wrapper/gradle-wrapper.properties; for example:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip
version 4.5 works stable and might not create the circular reference, alike 4.4 does. and when looking at the issues tracker on GitHub, this Gradle plugin might add more problems, than it would serve any real purpose - because the Android SDK already supports two-way data-binding.
currently the artifacts still list 8.8.1 as the latest version; while a SNAPSHOT is barely stable... that nothing happend there since over a year, hints for that this project might have been abandoned... most likely because of Architecture Components data-binding.
Android studio was taking up a massive amount of disk space on my computer (over 50 GB) and my old 90 GB ssd was completely full. I tried to reduce the amount of space that was being used by completely removing everything from android studio except my project and then reinstalling it.
There were some problems that I worked through, such as updating the sdk version, but I am stuck on this error message:
Error running app: This version of Android Studio is incompatible with the Gradle Plugin used. Try disabling Instant Run (or updating either the IDE or the Gradle plugin to the latest version)
I tried disabling instant run, but it did not fix the problem, and I like instant run anyway.
I also tried installing a new version of gradle and then pointing to it in settings/buildtools/gradle, and I've also tried checking the box to use the default wrapper instead.
I tried modifying my class path in build.gradle when I changed to gradle 3.0 in the settings above:
classpath 'com.android.tools.build:gradle:2.2.0-beta1'
My android studio is version 2.1.3/143.3101438
How do I get the right version of gradle installed and update my project to use it?
I got it working now. I had to specify the version of gradle in three places. First in settings/buildtools/gradle set it to use the default wrapper. Second specify the gradle version in build.gradle:
classpath 'com.android.tools.build:gradle:2.1.3'
Third, in gradle.wrapper.properties specify the gradle version:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
(I originally set it to ...gradle-2.13-all.zip, but it changed it to 2.14.1 after i put in 2.13, but it did not update the version in the build.gradle file)
I'm still very much confused what gradle is doing, why I need to specify the version 3 times, but at least it works.
So i'm trying to use Android Studio 2.2 preview-1 in Ubuntu 14.04 LTS.
I'm using gradle-2.10 and gradle-plugin 2.2.0-alpha1 along with openJDK-8.
compileSdkVersion 23
buildToolsVersion "23.0.3"
First the studio.sh didn't run and i found the solution to change #!/bin/sh to #!/bin/bash. Voila --it starts properly.
But in build.gradle files, warning is shown--
'dependencies' cannot be applied to '(groovy.lang.Closure)'
and its not finding imported class from library project(includes a jar only).
Please someone help me out.
The only fix that I found for this is, every time I open a project, I go to Settings>Build, Execution, Deployment>Gradle, change to "use local gradle distribution", click apply then click "use default gradle wrapper" and ok.
This should fix, but its quite annoying to do this everytime.
It Looks like a problem of version 2.10 of the wrapper version on gradle.
After reading around people's workaround like
"invalidate cache and restart"
delete .gradle file in the project and re-open it
etc etc
I just try for fun to install a standalone version of gradle since I'd always used only the wrapper version that cames with android studio.
And with it there is any error and any warning.
For anyone who wanna try (I'm a mac's user):
install gradle (by homebrew is fine and pretty easy) brew install gradle
tell to AS to use that one instead the wrapper version preference -> build, Execution, Deveployment -> Gradle -> use local gradle distribution
if you install it by homebrew like me the correct path will be: /usr/local/Cellar/gradle/x.yy/libexec
where x.yy it suppose to be 2.11 (that is the last version provide by brew even if the lastest version released is 2.13)
I've realised just now that the steps above doens't fix the definitly. Each time you re-open the project the problem came again and again.
It's annoying but changing betwen use of "wrapper"/"regular gradle" take the warning away.
But this means also that isn't a problem o the gradle as I'd assumed at the beginning.
...let's wait a permanent fix ^^
This issue is fixed in Android Studio 2.2 preview 2 (download from this page).
Disabled a couple of Groovy inspections that reported incorrect errors in build.gradle files
From the changelog.
In the build.gradle files, sometimes (I'm not sure when) you'll have to specify what version of gradle is used. The last few updates of Android Studio kept breaking some build files which listed the gradle version in use. I would have to update the gradle version number to fix the build file. I wanted to know if there's a way to figure out what version of gradle is included with Android Studio, instead of having to guess. I haven't been able to find out how to do this through Android Studio.
On Windows you can navigate to C:\Users\<user>\.gradle\wrapper\dists and you can see which gradle versions have been downloaded
If you're using gradle wrapper then you can change (or just check) gradle version number in gradle-wrapper.properties file. In order to do this you have to modify distributionUrl
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.
Go to Preferences > Project Settings > Gradle and choose "Use gradle wrapper" instead of the bundled option
Open your gradle-wrapper.properties and change the distributionUrl 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
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:
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.
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.
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
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.
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.