android studio报错:-source 1.7 中不支持 lambda 表达式(请使用 -source 8 或更高版本以启用 lambda 表达式)


android studio使用lambda表达式,需要配置两点

1.项目的build.gradle中需要写入 

dependencies {
    classpath 'me.tatarka:gradle-retrolambda:3.2.5'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
2.在程序的app.gradle中加入:
 
 
apply plugin: 'me.tatarka.retrolambda'

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

3.sync now  ok啦
 
 
 
 
使用  rxjava2 引入:
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.0.1'

猜你喜欢

转载自blog.csdn.net/nvcxy_1225/article/details/78606464