Androidの 错误lambda expressions are not supported at language level 7解决方法

android 工程中使用lambda表达式时,AS报错:

lambda expressions are not supported at language level 7。

解决方法
android {
    compileSdkVersion 30
    buildToolsVersion "30.0.1"

    defaultConfig {
        applicationId "com.steampy.app.all"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
    }
    //这个解决问题加入的
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }

}

如代码所示,添加编辑类型为1.8,即为java版本为8

compileOptions {
  sourceCompatibility = 1.8
  targetCompatibility = 1.8
}

你可能感兴趣的:(Androidの 错误lambda expressions are not supported at language level 7解决方法)