错误:来自jar文件的Lambda需要在类路径上编译其接口,未知接口为java.util.function.Function [英] Error:Lambda coming from jar file need their interfaces on the classpath to be compiled, unknown interfaces are java.util.function.Function
问题描述
我正在编写android项目.一些外部库需要使用Java8.但是,当我使用Jack添加Java8时,项目无法识别Java8的组件.可能是什么问题?
I am writing android project. Some of the external libraries requires the use of Java8. However, when I add Java8 using Jack, the project isn't recognizing the components of Java8. What might be the problem?
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.infiniteloop.android.translateyandex"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
jackOptions {
enabled true
}
}
dexOptions {
incremental true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildscript {
tasks.withType(JavaCompile) {
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
}
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.2.0'
compile 'com.github.vbauer:yandex-translate-api:1.2.5'
testCompile 'junit:junit:4.12'
}
这是错误列表 错误列表
推荐答案
您可以使用此 gradle插件,用于在Java 6、7和android中获得Java lambda支持
You can use this gradle plugin for getting java lambda support in java 6, 7 and android
只需添加:apply plugin: 'me.tatarka.retrolambda'
您的应用程序级别build.gradle文件中的以下行:apply plugin: 'com.android.application'
Just add: apply plugin: 'me.tatarka.retrolambda'
line in your app level build.gradle file below the line: apply plugin: 'com.android.application'
现在在您的项目级别build.gradle中添加:
Now in your project level build.gradle add :
classpath 'me.tatarka:gradle-retrolambda:3.6.0'
在您的依赖项部分
EG:
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'me.tatarka:gradle-retrolambda:3.6.0'
}
并同步它:)
这篇关于错误:来自jar文件的Lambda需要在类路径上编译其接口,未知接口为java.util.function.Function的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!