Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lambda expression in Android Library Module not working

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)

The code giving this error is,

Runnable r= () -> {
      appManager.startApp(definition,identifier);
};

My Build Gradle is

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'
}

What is the reason for this problem?

like image 423
chamathabeysinghe Avatar asked Aug 02 '17 06:08

chamathabeysinghe


1 Answers

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)

like image 148
Roy Avatar answered Sep 18 '22 17:09

Roy