android: 在android studio中使用retrolambda的步骤

找了各种说明,包括retrolambda官方文档都没有试成功
最后在这个链接中找到答案:http://blog.csdn.net/qq_26819733/article/details/52225653   

开发环境:
1)android studio 2.3.1
2)jdk:jdk8.0
3)新建工程的minSdkVersion,15

测试环境:
1)荣耀6,安卓4.4.2
2)Mate8,安卓7.0
亲测有效。


具体步骤如下:
1)在Project gradle config file的如下位置增加classpath
buildscript{
    dependencies{
        classpath 'com.android.tools.build:gradle:2.3.1'
        //step1, 我加的
   classpath 'me.tatarka:gradle-retrolambda:3.2.5'
    }
}

2)在Project Gradle config file的如下位置增加plugin
allprojects {
repositories {
jcenter()
////step2, 我加的
apply plugin: 'me.tatarka.retrolambda'
}
}
以上两步如下图所示。
 
2)在App Gradle config file的如下位置增加compileOptions
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
//step3, 我加的
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
  ...
}
 
原文地址:https://www.cnblogs.com/strinkbug/p/6839097.html