Android studio项目支持lambda表达式简化代码

1.项目名称/build.gradle中的dependencies中加

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath 'me.tatarka:gradle-retrolambda:3.4.0'//retrolambda
        
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

2.app/build.gradle中apply后添加

buildscript {
    repositories {
        mavenCentral()
        maven { url "https://jitpack.io" }
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'me.tatarka:gradle-retrolambda:3.4.0'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

 

android {
    ...

    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
        incremental = false
    }

    ...
}

 

你可能感兴趣的:(Android)