Retrolambda - Jack is required to support java 8 - warning fix
Asked Answered
C

4

22

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.

Crookes answered 6/7, 2016 at 12:21 Comment(5)
it's not a warning, it's just an information. so why bother turning it off?Authenticity
Don't you just love when things are clean? Actually it looks awful in jenkins, because there are like 30 lines of it. I know it's not that big a deal, but if it's quick fix why not to bother?Crookes
30 lines? that's interesting, I've got "only" 8 of them. anyways. no, I really don't care about these things. (If it was a real warning that would be different)Authenticity
did you manage to solve this issue?Heshum
Sadly I could not:(Crookes
U
14

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
    }
Uranography answered 6/7, 2016 at 12:46 Comment(1)
This does not answer the question.Ectoblast
A
5

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.

Alcaide answered 6/7, 2016 at 12:57 Comment(6)
nope, that won't get rid of the messages (and it's afaik a must to add these lines if you use retrolambda)Authenticity
Well, have you actually tried it? Looking at the source code of the retrolambda plugin shows me that it does exactly as I described, and I just tested that the Jack warning goes away if the compatibility settings are not set to VERSION_1_8.Alcaide
I'm not the OP, but I know that I've got those lines in my build.gradle and I still get the info - maybe I need an update of retrolambda, then.Authenticity
Tested it with android gradle plugin version 2.1.0, buildToolsVersion 24, retrolamba plugin 3.2.5 and 3.3.0-beta4 (latest) and the info message is gone.Alcaide
I've tried that, and now Android Studio says that language level is incompatible with lambda expression, and fix adds those lines back to build.gradle:) You didn't have this issue?Crookes
Ah I tested only on the command line with gradle. It's a pity Android Studio complains about, then I guess you don't have a choice.Alcaide
Z
1

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)

Zinkenite answered 16/12, 2016 at 15:49 Comment(0)
G
-1
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'

}
Glosso answered 19/5, 2017 at 7:37 Comment(1)
You should not be using this jackOptions { enabled true } Jack project was closed, when Android Studio 3.0 get's to stable channel you can remove retrolambda from project as this is already working perfectly there!Crookes

© 2022 - 2024 — McMap. All rights reserved.