简体   繁体   中英

How to use JDK 7 in Android Studio 2.3?

I want to build a project that required JDK 7, and I tried : navigate to

File > Project Structure > SDK Location 

and change the path to JDK 7, but an error was appeared please choose JDK 8 or newer

Is there a way to use JDK 7 in Android Studio 2.3? Or I should use an older version of Android Studio?

Edit

I uninstall all JDK and then install JDK 7, and it's work!

Try to set the java home as correct path in environment variables. Check your java location in environment variable. Open cmd and type java -version and if it is not java 7 change it in the environment variable.

please check the current version of java in your machine go to terminal and do

java -version

check if it's 1.7.x

use the below command to find java path

echo $JAVA_HOME

suggestion -Android Studio does not like spaces in the paths to the Android SDK and the JDK. Installing the JDK in a location that does not contain any spaces allowed to update the location through the Project Structure window.

In build.gradle :

android {
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM