Retrolambda - Jack is required to support java 8 -

2019-03-22 22:04发布

Is there a way to disable warning about

Jack is required to support java 8 language features.

while using Retrolambda?

I don't want jack support for now since it doesn't yet compile our project.

4条回答
Bombasti
2楼-- · 2019-03-22 22:18

You can just remove the following configuration from your build.gradle file:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

The retrolambda plugin will take care of this anyway and setup the Java compiler task with the correct source and target compatibility settings.

查看更多
别忘想泡老子
3楼-- · 2019-03-22 22:27
apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "io.github.rxandroid"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        jackOptions {
            enabled true

        }

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

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:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'

    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'io.reactivex:rxjava:1.3.0'
    compile 'com.jakewharton:butterknife:8.6.0'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.2.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.2.0'

}
查看更多
做个烂人
4楼-- · 2019-03-22 22:31

I confirm it is safe to remove VERSION_1_8 reference in build.gradle. Furthermore if one set jack support to true at the same time at setting JAVA Version to 1.8 and using Retrolambda, the following error kicks in:

java.lang.NullPointerException (no error message)

查看更多
手持菜刀,她持情操
5楼-- · 2019-03-22 22:44

android studio

Add below codes in your application gradle after that do synck

// ----- add
buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'me.tatarka:gradle-retrolambda:3.2.4'
    }
}

repositories {
    mavenCentral()
}
// ----- end

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda' // ----- add 

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

//----add
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
查看更多
登录 后发表回答