1,整个build文件
apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion "26.0.2" defaultConfig { applicationId "com.bwie.java8" minSdkVersion 19 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" jackOptions { enabled true } } compileOptions {//指定java版本 sourceCompatibility 1.8 targetCompatibility 1.8 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:26.0.0-alpha1' testCompile 'junit:junit:4.12' }
2.需要配置的是
第一块:
jackOptions {
enabled true
}
第二块
compileOptions {//指定java版本
sourceCompatibility 1.8
targetCompatibility 1.8
}
对照上面代码,放对位置即可!