在project的build.gradle文件中添加:
buildscript {
repositories {
mavenCentral()
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
}
}
在app的build.gradle文件中添加:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion xx
buildToolsVersion "xx"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
然后点击Sync project
按钮即可.
原文链接 http://www.trojx.me/2017/01/06/android-java8-support/ 转载请注明出处