Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

androidstudio set java version 1.7

I'm trying to use java version 1.7 with android studio but unfortunately it is not working properly... If set the version in File->Other settings -> Default project structure to

  Project SDK:
  java version 1.7.0_06

  Project language level:
  7.0 Diamonds, ARM, multi-catch

But when I use a switch-statement with a string I get an error which should be possible in java 1.7, so do I need to set any other settings?

like image 562
wasp256 Avatar asked Aug 26 '13 11:08

wasp256


People also ask

Can I use JDK 17 for Android Studio?

As per the docs, JDK 17 isn't supported yet in Android Studio. Actually, JDK 11 was supported starting from version 4.2 which was released in April 2021.

How do I change the default Java in Android Studio?

Set the JDK version Open your project in Android Studio and select File > Settings... > Build, Execution, Deployment > Build Tools > Gradle (Android Studio > Preferences... > Build, Execution, Deployment > Build Tools > Gradle on a Mac). Under Gradle JDK, choose the Embedded JDK option. Click OK.

Which version of Java is used in Android Studio?

Android Gradle plugin 3.0. 0 and later support all Java 7 language features and a subset of Java 8 language features that vary by platform version. When building your app using Android Gradle plugin 4.0. 0 and higher, you can use a number of Java 8 language APIs without requiring a minimum API level for your app.

Can I use Java 11 in Android?

Android SDK tools are not yet compatible with Java 11 and need Java 8 (1.8) to run correctly. The Bitrise stacks provide both Java 8 and Java 11, with Java 8 being active by default. If you need a Java 11 runtime for your project to compile, you can switch to Java 11 only before it's needed by the next Step.


2 Answers

No... there is no settings to change. Android SDK don't support full java 7 syntax, so you can't use it.

Note that java.nio.* (new in java 7 API) is supported by latest android version.

like image 104
ben75 Avatar answered Oct 12 '22 15:10

ben75


You can change it in new Android studio version(0.8.X)

FIle-> Other Settings -> Default Settings -> Compiler (Expand it by clicking left arrow) -> Java Compiler -> You can change the Project bytecode version here

enter image description here

like image 21
San Avatar answered Oct 12 '22 15:10

San