2017-08-02 213 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'