Android库模块中的Lambda表达式不起作用 [英] Lambda expression in Android Library Module not working
问题描述
我有一个使用jdk 8并启用了杰克选项的android应用程序模块.然后,将其转换为Android库模块.然后,我必须从构建gradle中删除Jack选项.现在,当我尝试构建AAR文件时,Lambda表达式给了我以下错误.
I had an android app module which used jdk 8 and enabled Jack Options. Then I convert it to an Android Library module. And then I have to remove Jack Options from build gradle. And now the Lambda expression gives me below error when I try to build the AAR file.
Error:(59, 25) error: cannot find symbol method metafactory(Lookup,String,MethodType,MethodType,MethodHandle,MethodType)
给出此错误的代码是
Runnable r= () -> {
appManager.startApp(definition,identifier);
};
我的构建平台是
Apply plugin: 'com.android.library'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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(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:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
此问题的原因是什么?
推荐答案
在我的计算机上,我缺少文件$ANDROID_SDK/build-tools/28.0.3/core-lambda-stubs.jar
,因此我不得不使用Android Studio SDK管理器重新安装版本28.0.3的构建工具.
On my machine I was missing the file $ANDROID_SDK/build-tools/28.0.3/core-lambda-stubs.jar
, so I had to reinstall version 28.0.3 of the build tools using the Android Studio SDK manager.
(我必须选中显示软件包详细信息"才能查看构建工具版本的完整列表)
(I had to check 'Show package details' to see the full list of build-tools versions)
这篇关于Android库模块中的Lambda表达式不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!