I ran the following comment:
./gradlew app:installDebug
only to be met with the log:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '11.0.2'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
My version of gradle is 5.1.1:
------------------------------------------------------------
Gradle 5.1.1
------------------------------------------------------------
Build time: 2019-01-10 23:05:02 UTC
Revision: 3c9abb645fb83932c44e8610642393ad62116807
Kotlin DSL: 1.1.1
Kotlin: 1.3.11
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 11.0.2 (Oracle Corporation 11.0.2+9-LTS)
OS: Mac OS X 10.13.6 x86_64
I'm not sure how to proceed (I tried upgrading/downgrading, but nothing has worked so far).
UPDATE: When I ran ./gradlew --version
, I got the following:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '11.0.2'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
My gradle-wrapper.properties
contains:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
In my case the JAVA_HOME
variable was set to /usr/lib/jvm/jdk-11.0.2/
. It was sufficient to unset the variable like this:
$ export JAVA_HOME=
Because wrapper version does not support 11+ you can make simple trick to cheat newer version of InteliJ forever.
press3x Shift -> type "Switch Boot JDK" -> and change for java 8.
https://blog.jetbrains.com/idea/2015/05/intellij-idea-14-1-4-eap-141-1192-is-available/
Or If you want to work with java 11+ you simply have to update wrapper version to 4.8+
cordova build android --release
I was able to resolve this, after trying so so many different things, by simply doing :
npm install cordova -g # to upgrade to version 10.0.0
cordova platform rm android
cordova platform add android # to upgrade to android version 9.0.0
I ran into a similar issue. I deleted these:
contents of the build folder.
then rebuild.
* DON'T FORGET TO BACKUP YOUR PROJECT FIRST *
tl;dr: downgrade java by running update-alternatives
My system gradle version was 4.4.1, and the gradle wrapper version was 4.0. After running the command given by several other answers:
gradle wrapper --gradle-version 4.4.1
I still had the same error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '11.0.4'.
It turns out java 11 wasn't supported until gradle 4.8, and my software repositories only had 4.4.1. (Also, upgrading to newer gradle version might have been incompatible with the package I was trying to compile.)
The answer was to downgrade java. My system actually had java8 already installed, and it was easy to switch between java versions by running this command and following the instructions:
sudo update-alternatives --config java
I ran into the same issue in Ubuntu 18.04.3 LTS. In my case, apt installed gradle version 4.4.1. The already-install java version was 11.0.4
The build message I got was
Could not determine java version from '11.0.4'.
At the time, most of the online docs referenced gradle version 5.6, so I did the following:
sudo add-apt-repository ppa:cwchien/gradle
sudo apt update
sudo apt upgrade gradle
Then I repeated the project initialiation (using "gradle init" with the defaults). After that, "./gradlew build" worked correctly.
I later read a comment regarding a change in format of the output from "java --version" that caused gradle to break, which was fixed in a later version of gradle.
As distributionUrl
is still pointing to older version, upgrade wrapper using:
gradle wrapper --gradle-version 5.1.1
Note: Use gradle
and not gradlew
Updating gradle/wrapper/gradle-wrapper.properties
with the following version fixed it for me:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
I had a similar problem: my default gradle wrapper
was version 4.x, while the support for higher versions of Java has been added in Gradle 5.
I've updated my gradlew
as described here: https://docs.gradle.org/current/userguide/gradle_wrapper.html#sec:upgrading_wrapper
TLTD:
./gradlew wrapper --gradle-version 5.6.2
I had the same problem here. In my case I need to use an old version of JDK and I'm using sdkmanager to manage the versions of JDK, so, I changed the version of the virtual machine to 1.8.
sdk use java 8.0.222.j9-adpt
After that, the app runs as expected here.
I've had the same issue. Upgrading to gradle 5.0 did the trick for me.
This link provides detailed steps on how install gradle 5.0: https://linuxize.com/post/how-to-install-gradle-on-ubuntu-18-04/
I was facing the same issue in Docker setup, while I was trying to install Gradle-2.4
with JDL 11.0.7
. I have to install a later version to fix the issue.
Here is the Working Dockerfile
FROM openjdk:11.0.7-jdk
RUN apt-get update && apt-get install -y unzip
WORKDIR /gradle
RUN curl -L https://services.gradle.org/distributions/gradle-6.5.1-bin.zip -o gradle-6.5.1-bin.zip
RUN unzip gradle-6.5.1-bin.zip
ENV GRADLE_HOME=/gradle/gradle-6.5.1
ENV PATH=$PATH:$GRADLE_HOME/bin
RUN gradle --version
To put long answer short, upgrade your gradlew
using the system gradle
tool. Note that the below upgrade works even if your system gradle
version is < 5
.
gradle wrapper --gradle-version=5.1.1
In my case, I was trying to build and get APK for an old Unity 3D project (so that I can play the game in my Android phone). I was using the most recent Android Studio version, and all the SDK packages I could download via SDK Manager in Android Studio. SDK Packages was located in
C:/Users/Onat/AppData/Local/Android/Sdk
And the error message I got was the same except the JDK (Java Development Kit) version "jdk-12.0.2" . JDK was located in
C:\Program Files\Java\jdk-12.0.2
And Environment Variable in Windows was JAVA_HOME : C:\Program Files\Java\jdk-12.0.2
After 3 hours of research, I found out that Unity does not support JDK 10. As told in https://forum.unity.com/threads/gradle-build-failed-error-could-not-determine-java-version-from-10-0-1.532169/
. My suggestion is:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Computer/This PC>Properties>Advanced System Settings>Environment Variables>New>Variable Name: JAVA_HOME>Variable Value: [YOUR JDK Path, Mine was "C:\Program Files\Java\jdk1.8.0_221"]
Edit > Preferences > External Tools and fill in the JDK path (Mine was "C:\Program Files\Java\jdk1.8.0_221")
.Android Studio > SDK Manager > Android SDK > Android SDK Location
.)I solved this by clicking on File -> Project Structure then changed the JDK Location to Use Embedded JDK (Recommended)
got to project file.. gradle/wrapper/gradlewrapper.properties
there you can change the value of distributionurl
to what ever the lastest version is. (Found on docs.gradle.org)
Source: Stackoverflow.com