Faced with `org.gradle.api.ProjectConfigurationException` error on my `gradle build`
I was able to solve this issue by reading the output log from the gradle daemon and below is the relevant line that helped me fix it.
14:52:50.575 [INFO] [org.gradle.launcher.daemon.server.Daemon] start() called on daemon - DefaultDaemonContext[uid=03e55abd-dc5a-42c5-bc7f-fc25f6a78bcb,javaHome=/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home,daemonRegistryDir=/Users/user_name/.gradle/daemon,pid=16809,idleTimeout=10800000,daemonOpts=-Xmx1536m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]
So, the gist is that the gradle settings and Android Studio settings work independent of each other. Gradle relies on the JAVA_HOME env var while starting up a daemon and making your build, when org.gradle.java.home
isn't explicitly set in properties.
Therefore, when rolling back to a different JVM, make sure to set the JAVA_HOME env var to that specific JVM (if you use the same JVM across all your applications) or set daemon specific setting like below in your gradle.properties
file visible at the project level :
org.gradle.java.home=/Library/Java/JavaVirtualMachines/<jdk_version>/Contents/Home
Please note that the above is my path and I use a Mac. It may be different on other platforms.
The issue is reported in Google's issue tracker here: https://issuetracker.google.com/u/1/issues/72872257
According to the comments, the issue should be fixed in 3.2.0-alpha09.
As a workaround, it's also possible to update gradle.properties with: android.enableD8.desugaring=true
Root cause is the use of Java 9 or higher for doing gradle tasks. It should be Java 1.8
java --version
will show you which Java version is utilized.
To fix Java version to an installed Java 1.8, below shell command resolve it.
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_{your installed version}.jdk/Contents/Home
Or, you can set gradle.properties
for each project as below.
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_{your installed version}.jdk/Contents/Home
source: https://gist.github.com/schnell18/bcb9833f725be22f6acd01f94b486392