25

I would like to set the Java version I'm using on Android Studio.

How do I set the 'Project language level' like I do on Intellij inside 'Project Structure...' --> 'Project'?

Hadas Kaminsky
  • 1,285
  • 1
  • 16
  • 39
  • 1
    Check this - http://stackoverflow.com/questions/20270190/how-to-choose-language-level-for-new-project-in-android-studio – hagrawal7777 Nov 25 '15 at 15:34
  • 1
    Thanks, saw this question but this is a dialog for a new project and I'm already working on an existing one – Hadas Kaminsky Nov 25 '15 at 17:11
  • But you must have gone through that and there must be some provision of doing it again for existing one .. In Android studio I am not sure but I in Eclipse I can update things after also .. – hagrawal7777 Nov 25 '15 at 17:16
  • 1
    @hagrawal Yes there should be such an option, but there isn't (an intuitive one). Look here (android studio 2.1) http://imgur.com/XY8rupT. In Intellij this is where you set the project language, in Android studio it is empty. – peer May 01 '16 at 19:54
  • Thanks @peer. So, what do you do if you want to change the java version? – Hadas Kaminsky May 03 '16 at 02:34
  • @Hadas No idea, sorry... I'm afraid one has to edit the gradle files – peer May 03 '16 at 13:48

3 Answers3

35

You can also edit this inside the Project Structure

enter image description here

6rchid
  • 1,074
  • 14
  • 19
15

Sample build.gradle file which allows me to use lambdas in Android Studio 2.1:

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.geniuscreations.successtaskanalyzer"
    minSdkVersion 17
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    jackOptions {
        enabled true
    }
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

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

Java 8 Language Features | Android Developers

Sameer Achanta
  • 383
  • 4
  • 18
2

Add this to your build.gradle(Module:app):

android{
...

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

...
}
Sayooj
  • 766
  • 5
  • 23