When I try to build the project:
5:33 pm Gradle sync started
5:33 pm Gradle sync failed: Could not determine java version from '11.0.8'.
The project uses Gradle version which is incompatible with Studio running on Java 10 or newer.
See details at https://github.com/gradle/gradle/issues/8431
Possible solution:
- Upgrade Gradle wrapper to 4.8.1 version and re-import the project
(2 s 910 ms)
5:33 pm Android Studio is using the following JDK location when running Gradle:
/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
Using different JDK locations on different processes might cause Gradle to
spawn multiple daemons, for example, by executing Gradle tasks from a terminal
while using Android Studio.
More info...
Select a JDK from the File System
Do not show this warning again
When I press the link to upgrade Gradle:
Could not determine java version from '11.0.8'.
The project uses Gradle version which is incompatible with Studio running on Java 10 or newer.
See details at https://github.com/gradle/gradle/issues/8431
Possible solution:
- Upgrade Gradle wrapper to 4.8.1 version and re-import the project
It is saying I have Java 11.0.8 when the JDK location is very clearly pointing at Java 8, and changing the Gradle version fails.
The steps I took to fix this were to make sure JDK was < 10 which it states it has to be. Since JDK = 8, this should be fulfilled.
Thanks for any advice.
Related
I am trying be build a java application using "gradlew build". I have installed gradle 7.3.3
and I have java 11.0.10.
From other answers I understand that gradle is compatible with older version but here I have java 11 and latest gradle still I am getting this error.
I also tried following gradle wrapper --gradle-version 7.3.3 but it is giving me following error:
Can anyone suggest what I am missing or should differently.
EDIT: (Content of gradle.wrapper.propertiese file)
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://server_path/gradle/4.6/gradle-4.6-bin.zip
Thanks
After doing some research I found the resolution, posting so that it might help someone else.
NOTE: the gradle you installed on your machine and the gradle used by the project you are trying to build might be different. If you are in bad luck then they might be incompatible based on java version you have on your system.
I had gradle 7.3.3 on my system and the project was using gradle 4.6. The gradle used by project is not compatible with java 11. So, to be on safe side I downgraded both Gradle (to v 4.6) and java (to 1.8) and it worked.
You might not required to downgrade the gradle version on your local machine. I will try that as well and update this answer.
EDIT: It worked with Gradle 7.3.3, java 1.8 and the project using Gradle 4.6.
Just trying to create a Gradle project using the jdk17, facing the below issue. I know Gradlew 7.3 is required for JDK 17, but quite not sure from where I should set the version of Gradle
Gradle location
Gradle version
It's because the current version of IntelliJ (2021.2.3) is not aware of gradle 7.3.
To get around the issue:
Press "Yes" on the dialog.
When the project is created, change distributionUrl in gradle/wrapper/gradle-wrapper.properties to https\://services.gradle.org/distributions/gradle-7.3-bin.zip.
After you refresh the project it should be able to build.
I've reproduced the same issue:
Unsupported Project JDK
Cannot find supported Gradle version for JDK 17. The Gradle supports
JDK versions 7 through 16.
using Java 17 & Gradle 7.3 & Windows 10.
But, as I see from matrix of compatibility, there must be no issue with Java 17 & Gradle 7.3:
As temporary workaround it can be solved using Java 15 instead of Java 17 with Gradle 7.3, but for me it looks like a bug related to Intellij IDEA 2021.2.2 (Ultimate Edition | Build #IU-212.5284.40, built on September 14, 2021) + Java 17, so I opened a ticket on YT:
Cannot find supported Gradle version for JDK 17. The Gradle supports JDK versions 7 through 16.
Also I've reproduced the same issue using versions of Gradle:
5.6.4, 6.1, 7.1, 7.3
with Java 17 in Intellij IDEA until I downgraded to Java 15.
To be noticed: this is a bug which is specifically related to Java 17 + Intellij IDEA 2021.2.2 (Ultimate Edition | Build #IU-212.5284.40, built on September 14, 2021) and it's not related to GRADLE_HOME + GRADLE_HOME/bin.
I somehow got Java 17 with Gradle 7.2 working (with IntelliJ IDEA 2021.2.2 Community Edition and Windows 10).
I had Gradle 7.2 installed separately. This is what I configured within IntelliJ:
File » Settings
Then on the left navigation menu Build, Execution, Deployment » Build Tools » Gradle
Set Gradle JVM to 17
Set Use Gradle from: to Specified location and select the path to Gradle 7.2.
You could also try to explicitly set the Java language version within build.gradle:
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
Assuming that you're looking to switch versions of gradle, the best way forward is to use a version manager.
I personally use sdkman which is Open source and provides support for major tools like Java, Maven, Gradle and others.
The benefit is you can install multiple versions and switch between them without dealing with env vars.
# installing
$ sdk install gradle 6.7.1
# switching version
$ sdk use gradle 6.7.1
# set as default version
$ sdk default gradle 6.7.1
The 2021.2 IDE version uses 7.2 Gradle version for new projects. At the moment of that IDE version release, there was no Gradle version that supported 17 JDK version. Now, you can update to 2021.3 IDE version where the Gradle version has been updated to 7.3 which now supports 17 JDK. The preview build is available from this page.
I'm not sure which version of IntelliJ you're using, it maybe ships with Gradle 7 version. In my case also 7 version, but after creating project, just set gradle 7.3 location in preference. For me, gradle 7.3 builds JDK 17 successfully.
Spring Boot Project
I'm using gradle 5.2.1 I can't change the version because I'm working on someone else's code. When I build the project in IntelliJ I get the following error:
* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokeHelper
I'm using IntelliJ terminal in my code folder with command ./gradlew clean build install.
when I check ./gradle -version it shows JVM: 16.0.2
I feel the problem is with my jdk version.
As per compatibility matrix , only gradle versions of 7 are supporting java 16.
May be you can use older version of jdk which is supporting your current gradle.
I downloaded the libGDX setup jar file, I generated a project and imported it (to eclipse). Once I try to run the project eclipse outputs an error:
Description Resource Path Location Type
Could not create an instance of Tooling API implementation using the specified Gradle distribution 'https://services.gradle.org/distributions/gradle-4.6-bin.zip'.
Could not create service of type FileMetadataAccessor using NativeServices.createFileMetadataAccessor().
Could not determine java version from '11.0.2'.
I have no idea how to solve this problem.
The problem is that you are using Java 11. Try it with Java 8. The HTML module does not compile with a Java version greater then 8.
Gradle 4.6 likely does not support Java 11.
You can either upgrade to a newer version of Gradle or downgrade your JDK version.
I would recommend updating to Gradle 4.10.2 as it is the latest Gradle 4 variant (you can try Gradle 5 however it may introduce some breaking changes)
This can be done by running in the root of your project:
Linux / MacOS:
./gradlew wrapper --gradle-version=4.10.2
Windows:
gradle wrapper --gradle-version=4.10.2
I am trying to build a simple android project on the command line using
android create project
I am following this tutorial, and using android-sdk tools version 25.2.5 which still includes the above command. However, my gradle version is 4.8.1 and java 10.0.1.
First, I cd into my project folder and use the android command to create a project:
android create project -p . -a MainActivity -k com.test.firstapp -t "android-22" -g -v 2.3.0
This gives me a project frame. I chose the android gradle plugin version 2.3.0 based on this web page, hoping it would support all newer versions of gradle as well.
Then I try to build the project with
./gradlew build
and get my first error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '10.0.1'.
So I reckoned there must be a mismatch with the gradle version and the gradle plugin version I am using because gradle 4.8.1 should definitely support java 10.0.1. I then went and looked at my build.gradle file in the project directory and changed the android plugin version to 3.1.0, as follows:
classpath 'com.android.tools.build:gradle:3.1.0'
also adding google() to the repositories. I still got the same java version error. Now, I had a look at gradle/wrapper/gradle-wrapper.properties and saw that the distributionUrl was for gradle 1.12, so I changed it to my actual version:
distributionUrl=http\://services.gradle.org/distributions/gradle-4.8.1-all.zip
After changing the gradle version in the wrapper, I call:
gradle wrapper --gradle-version 4.8.1
as advised here. Running this, I first get a warning and and error:
Configure project :
WARNING: The specified Android SDK Build Tools version (22.0.1)
is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.0.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '22.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
File /home/user/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Build-Tools 27.0.3 in /opt/android-sdk/licenses
License for package Android SDK Build-Tools 27.0.3 accepted.
Preparing "Install Android SDK Build-Tools 27.0.3 (revision: 27.0.3)".
Warning: Failed to read or create install properties file.
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
* Where:
Build file '/home/user/dev/android/firstapp/build.gradle' line: 18
* What went wrong:
A problem occurred evaluating root project 'firstapp'.
> Could not find method runProguard() for arguments [false] on BuildType_Decorated{name=release, debuggable=false, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, minifyEnabled=false, zipAlignEnabled=true, signingConfig=null, embedMicroApp=true, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}} of type com.android.build.gradle.internal.dsl.BuildType.
I'm sure it's a mismatch of versions but could someone point out what the right combination is if I want to keep working with android-sdk tools 25.2.5?
I'm doing this on Ubuntu 16.04.
Thanks.
In the end, the combination that works for me was the following:
android sdk tools 25.2.5
android build tools 26.0.2
platform-tools 28.0.0 (uncritical in any case...)
java 8 (indeed had to downgrade)
gradle 4.8.1
android gradle plugin 3.0.1
With this combination I was able to create a project using 'android create project' and build with './gradlew build':
> android create project -p . -a MainActivity -k com.test.firstapp -t "android-22" -g -v 3.0.1
> Created directory ....
The android tool still creates some deprecated input into build.gradle, such as proguard instead of minifyEnabled, and leaves out some repositories (google(), jcenter()) that I need to find the newer gradle plugin version, among other things. Also, the gradle-wrapper.properties sill contain an outdated gradle version url but that can be changed as shown in my original question. I'm a lot closer to automating project creation from the command line than before even if it's not perfect.