小编giu*_*ha9的帖子

从jack迁移到本机Java 8

我正在尝试在我的Android项目中使用lambda表达式和流.我正在使用streamsupport库来实现流,而将本地Java 8用于lambda表达式.为了能够使用我需要添加的Java 8功能

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
Run Code Online (Sandbox Code Playgroud)

这个代码在我的gradle中,但是编译器显示了这个错误:

Error:Jack is required to support java 8 language features. Either enable Jack or remove sourceCompatibility JavaVersion.VERSION_1_8.
Run Code Online (Sandbox Code Playgroud)

然后我加了这个

jackOptions {
    enabled true
}
Run Code Online (Sandbox Code Playgroud)

并且编译器没有错误,但在运行时,同样的错误不断显示. 这是我的傻瓜

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"

    defaultConfig {
        applicationId "home.gio.calorieplanner"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' …
Run Code Online (Sandbox Code Playgroud)

java android java-stream android-jack-and-jill

7
推荐指数
1
解决办法
2122
查看次数