I ran into a problem when the Gradle daemon (as it was started by Android Studio through the API) uses a different version of Java than when running through the command line.
I have no value set for JAVA_HOME, and java is in my path:
java -version
java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)
I wrote a task for debugging:
task printDebug << {
println "command: " + System.getProperty("sun.java.command");
println "JAVA_HOME: " + System.env.'JAVA_HOME';
println "Java Version: " + org.gradle.internal.jvm.Jvm.current();
}
which when launched through Studio produces:
command: org.gradle.launcher.daemon.bootstrap.GradleDaemon 2.8
JAVA_HOME: null
Java Version: 1.7.0_71 (Oracle Corporation 24.71-b01)
but when launched through the command line it creates:
command: org.gradle.wrapper.GradleWrapperMain printDebug
JAVA_HOME: null
Java Version: 1.8.0_72 (Oracle Corporation 25.72-b15)
What does the java executable look like for the Gradle daemon? How does it start? For what it's worth, Android Studio uses the expected version of Java (1.8), as reported in "About Android Studio."
source
share