在 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'
}
编辑:修改 main 构建文件以包含来自 https://stackoverflow.com/users/5753091/mohammadreza-khalifeh 的答案- 但这没有帮助
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
看起来路径中的空格可能会导致问题?
编辑:尝试:
options.compilerArgs << "\""+"-Xbootclasspath/a:" + System.properties.get("java.home") + "/lib/rt.jar"+"\""
也不行。
最佳答案
将 Guava
库添加到我的依赖项后,我遇到了这个问题。
解决方案是将 lib 版本从 com.google.guava:guava:21.0
降级为 com.google.guava:guava:20.0
。
另外,我正在使用类路径 'com.android.tools.build:gradle:2.5.0-alpha-preview-01`
编辑:由于您不使用此库,请尝试更改:
- 在项目中
build.gradle
- 从
classpath 'com.android.tools.build:gradle:2.2.0'
到com.android.tools.build:gradle:2.5.0-alpha-preview- 的类路径01
- 从
在应用中
build.gradle
- 从
compileSdkVersion 24
到25
- 从
buildToolsVersion "24.0.2"
到25.0.2
- 从
在
gradle-wrapper.properties
- 将版本更改为
distributionUrl=https://services.gradle.org/distributions-snapshots/gradle-3.5-20170213202653+0000-all.zip
- 将版本更改为
关于java - Android Jack : Lambda coming from jar file need their interfaces on the classpath to be compiled, 未知接口(interface)是 java.util.function.Consumer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39683608/