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).
As per the docs, JDK 17 isn't supported yet in Android Studio.
Open your gradle. properties file in Android Studio. Restart Android Studio for your changes to take effect. Click Sync Project with Gradle Files to sync your project.
Java 7 support was added at build tools 19. You can now use features like the diamond operator, multi-catch, try-with-resources, strings in switches, etc. Add the following to your build.gradle
.
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
Gradle 1.7+, Android gradle plugin 0.6.+ are required.
Note, that only try with resources require minSdkVersion
19. Other features works on previous platforms.
Link to android gradle plugin user guide
Link to see how source vs target are different
Maybe these answers above are old but with the new Android Studios 1, you do the following to see the module to run on 1.7 (or 1.6 if you prefer). Click File --> Project Structure. Select the module you want to run and then under "Source Compatibility" and "Target Compatibility", select 1.7. Click "OK".
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
Latest Android Studio 1.4.
Click File->Project Structure->SDK Location->JDK Location.
You could also set individual module JDK Version compatibility by going to the Module (below the SDK Location), and edit the Source Compatibility accordingly. (note, this only applies to Android Module).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With