I use Android Studio and recently got the error:
Error:Execution failed for task \':app:compileDebugJavaWithJavac\'. compileSdkVersion \'android-24\' re
I was also running into the same issue from the command line on my Mac, but the answer was that JAVA_HOME
was getting overridden. To track down where it is getting overridden first check java from the command line:
$ java -version
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
Then check which version of Java that Gradle is using:
$ gradle -version
------------------------------------------------------------
Gradle 2.13
------------------------------------------------------------
Build time: 2016-04-25 04:10:10 UTC
Build number: none
Revision: 3b427b1481e46232107303c90be7b05079b05b1c
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_92 (Oracle Corporation 25.92-b14)
OS: Mac OS X 10.11.5 x86_64
At this point, I still hadn't found the source of the problem. Did a little digging, and found that it was indeed overridden in my gradle.properties
file even though it was showing Java 8 when I executed gradle -version
:
org.gradle.daemon=true
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
org.gradle.jvmargs=-XX:MaxPermSize=512m -XX:-UseSplitVerifier -Xms512m -Xmx6144m
To fix, I just deleted the java.home
line from gradle.properties
. Hopefully this helps if anyone else is running into the same issue from the command line.