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.

miszmaniac
  • 825
  • 2
  • 10
  • 21

4 Answers4

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
    }
Shreyash Mahajan
  • 23,386
  • 35
  • 116
  • 188
loadjang
  • 327
  • 1
  • 3
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.

T. Neidhart
  • 6,060
  • 2
  • 15
  • 38
  • 2
    nope, that won't get rid of the messages (and it's afaik a must to add these lines if you use retrolambda) – Lovis Jul 06 '16 at 13:21
  • 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. – T. Neidhart Jul 06 '16 at 13:37
  • 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. – Lovis Jul 06 '16 at 14:59
  • 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. – T. Neidhart Jul 06 '16 at 15:24
  • 5
    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? – miszmaniac Jul 07 '16 at 07:45
  • 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. – T. Neidhart Jul 07 '16 at 07:48
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)

Community
  • 1
  • 1
ebarault
  • 126
  • 5
-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'

}
Trinadh Koya
  • 1,089
  • 15
  • 19
  • 2
    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! – miszmaniac May 22 '17 at 11:25