java 如何在 Android Studio 上更改项目语言级别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33920343/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 22:17:32  来源:igfitidea点击:

How do I change Project language level on Android Studio

javaandroid-studio

提问by Hadas Kaminsky

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

我想设置我在 Android Studio 上使用的 Java 版本。

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

如何设置“项目语言级别”,就像我在“项目结构...”->“项目”中的 Intellij 上所做的那样?

回答by 6rchid

You can also edit this inside the Project Structure

您还可以在项目结构中编辑它

enter image description here

在此处输入图片说明

回答by Sameer Achanta

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

示例 build.gradle 文件,它允许我在 Android Studio 2.1 中使用 lambda:

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.geniuscreations.successtaskanalyzer"
    minSdkVersion 17
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    HymanOptions {
        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

Java 8 语言特性 | 安卓开发者