【问题标题】:Retrolambda - Jack is required to support java 8 - warning fixRetrolambda - Jack 需要支持 java 8 - 警告修复
【发布时间】:2016-07-06 12:21:33
【问题描述】:

有没有办法关闭警告

需要 Jack 才能支持 java 8 语言功能。

在使用 Retrolambda 时?

我现在不想要 jack 支持,因为它还没有编译我们的项目。

【问题讨论】:

  • 这不是警告,它只是一个信息。那为什么还要关掉它呢?
  • 你不喜欢干净的东西吗?实际上它在 jenkins 中看起来很糟糕,因为它有 30 行。我知道这没什么大不了的,但如果能快速解决,为什么不打扰呢?
  • 30 行?这很有趣,我“只有”8 个。无论如何。不,我真的不在乎这些事情。 (如果是真正的警告,那就不一样了)
  • 你解决了这个问题吗?
  • 遗憾的是我做不到:(

标签: android android-gradle-plugin retrolambda


【解决方案1】:

您可以从build.gradle 文件中删除以下配置:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

retrolambda 插件无论如何都会处理这个问题,并使用正确的源和目标兼容性设置来设置 Java 编译器任务。

【讨论】:

  • 不,这不会消除消息(如果您使用 retrolambda,则必须添加这些行)
  • 嗯,你真的试过了吗?查看 retrolambda 插件的源代码,我发现它与我描述的完全一样,我刚刚测试了如果兼容性设置未设置为 VERSION_1_8,Jack 警告就会消失。
  • 我不是 OP,但我知道我的 build.gradle 中有这些行,我仍然可以得到信息 - 那么也许我需要更新 retrolambda。
  • 使用 android gradle 插件版本 2.1.0、buildToolsVersion 24、retrolamba 插件 3.2.5 和 3.3.0-beta4(最新)对其进行了测试,信息消息消失了。
  • 我试过了,现在 Android Studio 说语言级别与 lambda 表达式不兼容,并且修复将这些行添加回 build.gradle :) 你没有这个问题吗?跨度>
【解决方案2】:

我确认删除 build.gradle 中的 VERSION_1_8 引用是安全的。 此外,如果在将 JAVA 版本设置为 1.8 并使用Retrolambda 时同时将一组插孔支持设置为 true,则会出现以下错误:

java.lang.NullPointerException (no error message)

【讨论】:

    【解决方案3】:

    安卓工作室

    在您的应用程序 gradle 中添加以下代码,然后进行同步

    // ----- 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
        }
    

    【讨论】:

    • 这没有回答问题。
    【解决方案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'
    
    }
    

    【讨论】:

    • 你不应该使用这个jackOptions { enabled true } Jack 项目已关闭,当 Android Studio 3.0 进入稳定通道时,你可以从项目中删除 retrolambda,因为它已经在那里完美运行了!
    猜你喜欢
    • 2016-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-21
    • 1970-01-01
    • 2020-02-21
    • 2017-01-10
    相关资源
    最近更新 更多