Retrolambda - Jack is required to support java 8 - warning fix

谁说我不能喝 提交于 2019-12-04 15:40:07

问题


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.


回答1:


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
    }



回答2:


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:


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)




回答4:


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'

}


来源:https://stackoverflow.com/questions/38223882/retrolambda-jack-is-required-to-support-java-8-warning-fix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!