官網(wǎng)說明
要開始使用受支持的 Java 8 語言功能,請更新 Android 插件到 3.0.0(或更高版本)。 然后,針對使用(包括在源代碼中或通過依賴項(xiàng)使用)Java 8 語言功能的每個(gè)模塊,在其 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
}
即可使用lambda