解决 Error:Jack is required to support java 8 language features. Either enable Jack...

在AS 2.1中使用 Lambda 时 会出现

Error:Jack is required to support java 8 language features. Either enable Jack or remove sourceCompatibility JavaVersion.VERSION_1_8.

解决方法

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        jackOptions {
            enabled true
        }

    }

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

加入jackOptions

加入compileOptions

就可以使用Lambda表达式

你可能感兴趣的:(解决 Error:Jack is required to support java 8 language features. Either enable Jack...)