2017-08-02 216 views
2

我有一个android应用程序模块,它使用jdk 8并启用了Jack选项。然后我将它转换为Android库模块。然后我必须从构建gradle中删除Jack选项。现在,当我尝试构建AAR文件时,Lambda表达式给了我下面的错误信息。Android库模块中的Lambda表达式不起作用

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

,这是什么问题的原因是什么?

+0

你有没有找到一个解决办法? –

回答

0

你忘了应用复古的lambda插件。

此行添加到您的build.gradle文件:

apply plugin: 'me.tatarka.retrolambda'