Error:Jack is required to support java 8 language features. Either enable Jack or remove sourceCompatibility JavaVersion
解决办法:
在gradle中添加代码:
//使用Java1.8
jackOptions{
enabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
添加后如下:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '24.0.0'
// **兼容Android6.0系统所需,如果这句话报错,可在dependencies标签下使用compile 'cn.bmob.android:http-legacy:1.0'**
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "wang.fly.com.yunhealth"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
jackOptions{
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets{
main.jniLibs.srcDirs = ["libs"]
}
//使用Java1.8
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
android{compileOptions.encoding="GBK"}
}
repositories{
flatDir{
dir 'libs'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile name: 'SMSSDK-2.1.2', ext: 'aar'
compile name: 'SMSSDKGUI-2.1.2', ext: 'aar'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:recyclerview-v7:25.0.+'
compile 'io.reactivex:rxjava:1.2.0'
compile 'io.reactivex:rxandroid:1.2.0'
compile files('libs/MobCommons-2016.1012.1447.jar')
compile files('libs/MobTools-2016.1012.1447.jar')
}