Android Jack:来自jar文件的Lambda需要在类路径上编译接口,未知接口是java.util.function.Consumer [英] Android Jack: Lambda coming from jar file need their interfaces on the classpath to be compiled, unknown interfaces are java.util.function.Consumer

查看:177
本文介绍了Android Jack:来自jar文件的Lambda需要在类路径上编译接口,未知接口是java.util.function.Consumer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在android studio 2.2上获取此功能。

Getting this on android studio 2.2.

有没有人有解决方法?

我的应用构建文件是:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"

    defaultConfig {
        applicationId "acme.cb2"
        minSdkVersion 18
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        jackOptions {
            enabled true
        }

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.android.support:support-v4:24.1.1'
}

编辑:修改构建文件以包含来自 https://stackoverflow.com/users/5753091的答案/ mohammadreza-khalifeh - 但这没有帮助

edit: modifid the main build file to include answer from https://stackoverflow.com/users/5753091/mohammadreza-khalifeh - but this did not help

import java.text.SimpleDateFormat

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
        classpath 'org.hidetake:gradle-ssh-plugin:2.4.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xbootclasspath/a:" + System.properties.get("java.home") + "/lib/rt.jar"
        }
    }
}

编辑:添加:

options.compilerArgs.each { println 'option: '+it}

打印出来:

option: -Xbootclasspath/a:C:\Program Files\Java\jdk1.8.0_92\jre/lib/rt.jar

看起来路径中的空格可能会导致问题?

It looks like the space in the path might cause a problem?

编辑:尝试:

options.compilerArgs << "\""+"-Xbootclasspath/a:" + System.properties.get("java.home") + "/lib/rt.jar"+"\""

也不起作用。

推荐答案

Guava 库添加到我的依赖项后,我遇到了这个问题。

I had this problem after adding Guava library to my dependencies.

解决方案是从<$ c降级lib版本$ c> com.google.guava:guava:21.0 到 com.google.guava:guava:20.0

另外,我正在使用classpath'com.android.tools.build:gradle:2.5.0-alpha-preview-01`

Also, I'm using classpath 'com.android.tools.build:gradle:2.5.0-alpha-preview-01`

编辑:由于您不使用此库,请尝试在项目<$ c中更改:

As you don't use this library please try to change:


  • $ c> build.gradle


    • 来自 classpath的类路径'com.android.tools.build:gradle :2.2.0' com.android.tools.build:gradle:2.5.0-alpha-preview-01

    • in project build.gradle
      • classpath from classpath 'com.android.tools.build:gradle:2.2.0' to com.android.tools.build:gradle:2.5.0-alpha-preview-01

      在应用 build.gradle


      • 来自 compileSdkVersion 24 25

      • 来自 buildToolsVersion24.0.2 25.0.2

      • from compileSdkVersion 24 to 25
      • from buildToolsVersion "24.0.2"to 25.0.2

      in gradle-wrapper.properties


      • 将版本更改为 distributionUrl = https: //services.gradle.org/distributions-snapshots/gradle-3.5-20170213202653+0000-all.zip

      • change version to distributionUrl=https://services.gradle.org/distributions-snapshots/gradle-3.5-20170213202653+0000-all.zip

      这篇关于Android Jack:来自jar文件的Lambda需要在类路径上编译接口,未知接口是java.util.function.Consumer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆