5

I am able to build my Android project from Android Studio. However, I am getting following error when I try to run a gradlew command. How can I resolve this?

admin:(my/branch)$ ./gradlew clean assembleDebug --stacktrace

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine java version from '11.0.1'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
admin:(my/branch)$

This is my Java version:

admin:(my/branch)$ java -version
java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)
halfer
  • 19,824
  • 17
  • 99
  • 186
Hesam
  • 52,260
  • 74
  • 224
  • 365

2 Answers2

4

Upgrade to Gradle 4.7.

The Release Notes says:

Fixed issues

46 issues have been fixed in Gradle 4.7.

  • ...
  • [#4515] - Support Java 11 Version Name
  • ...
Community
  • 1
  • 1
Andreas
  • 154,647
  • 11
  • 152
  • 247
  • Thanks @Andreas for your answert. You are right. I just upgraded from `gradle-wrpper.propertise` file and I don't see the error. However, this time I see following error:```admin:(my/branch)$ ./gradlew clean FAILURE: Build failed with an exception. * What went wrong: Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory(). > Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().``` Have you seen such an issue? – Hesam Nov 16 '18 at 15:52
  • I uninstalled Java 11 and installed Java 8 instead. So, all complains are gone. – Hesam Dec 20 '18 at 15:35
1

You can either upgrade the Gradle version likes Andreas's answer or downgrade the java version if needed.

Follow the link to change JAVA_HOME to downgrade JAVA. How to set JAVA_HOME in Mac permanently?

Allen
  • 2,979
  • 1
  • 29
  • 34