While compiling i get the error Error:compileSdkVersion android-21 requires compiling with JDK 7
, saying that a newer version of JDK is required.
I\'m r
if you only have folder 1.6.0.jdk then go to this link and download and install jdk 1.7. then find your java folder in this path
/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
The Exact Fix for this Issue (Android Studio Users on Mac)
If you have already upgraded to Java 8, please note that the JDK location is now within /Library/Java
compared to Java 6's location /System/Library/Java
. So to fix this problem, Right click on the Project folder > Project Structure > SDK Location.
Then change JDK location to
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home
If you have installed a different JDK version (other than Java 8), find out the path using the java_home
script first and use the output. Just run,
/usr/libexec/java_home
The solutions on this thread are not valid for the same error in Android Studio 1.4 . The preferences menu, for example, is gone. Below is the solution for Android Studio 1.4 running on Ubuntu 14.04.
To solve in Ubuntu 14.04+ and Android Studio 1.4+, you need to go to
File -> Other Settings -> Default Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler -> Project Bytecode Version
This drop-down will be empty by default.
Set to your preferred JDK, in the case of the screencap below, 1.8 .
Voila, your project will compile.