我有一个 android 应用程序模块,它使用 jdk 8 并启用了 Jack Options。然后我将它转换为 Android 库模块。然后我必须从构建 gradle 中删除 Jack Options。现在,当我尝试构建 AAR 文件时,Lambda 表达式给出了以下错误。
Error:(59, 25) error: cannot find symbol method metafactory(Lookup,String,MethodType,MethodType,MethodHandle,MethodType)
给出这个错误的代码是,
Runnable r= () -> {
appManager.startApp(definition,identifier);
};
我的构建 Gradle 是
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
,所以我不得不重新安装版本 28.0.3 的构建工具使用 Android Studio SDK 管理器。
(我必须选中“显示包详细信息”才能查看构建工具版本的完整列表)
关于java - Android 库模块中的 Lambda 表达式不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45452827/