我测试了Java8的一些新特性,并将示例复制到我的集成开发环境中(最初是Eclipse,然后是IntelliJ),如here所示
Eclipse不提供对lambda表达式的任何支持,而IntelliJ一直报告错误
此语言级别不支持
Lambda表达式
我想知道这是否是我的安装、代码或支持方面的问题。
发布于 2014-03-28 13:05:24
在IntelliJ IDEA中:
在File Menu Project Structure Project→中,将Project Language Level更改为8.0 - Lambdas, type annotations etc.
对于安卓3.0+ Go File Project Structure Module和app→→,在属性选项卡中将Source Compatibility和Target Compatibility设置为1.8 (Java 8)
截图:

发布于 2015-05-29 14:12:59
您还应该在source选项卡(Modules part)上更改源代码语言级别。

发布于 2018-02-28 15:55:48
此解决方案适用于Android Studio 3.0或更高版本。

将Source Compatibility和Target Compatibility都更改为1.8
也可以直接在相应的build.gradle文件中对其进行配置
android {
...
// Configure only for each module that uses Java 8
// language features (either in its source code or
// through dependencies).
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}https://stackoverflow.com/questions/22703412
复制相似问题