When trying to build an android application from Jenkins using gradle, I get the following error:
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-8-oracle
Please set the JAVA_HOME variable in your environment to match the location of your Java installation.
Build step 'Invoke Gradle script' changed build result to FAILURE
Build step 'Invoke Gradle script' marked build as failure
Finished: FAILURE
However, when I check the JAVA_HOME variable I get:
Macs-Mac-mini:~ mac$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
Running java -version
.
Macs-Mac-mini:~ mac$ java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)
why does Gradle find /usr/lib/jvm/java-8-oracle
tried Gradle finds wrong JAVA_HOME and Gradle does not recognize the JAVA_HOME