2017-04-16 34 views
3

我正在使用RxJava2以及lambda。 IDE是Android Studio。編譯時遇到以下錯誤。錯誤:來自jar文件的Lambda需要它們的類路徑上的接口進行編譯RxJava2

信息:搖籃任務[:應用程序:generateDebugSources,:應用程序:mockableAndroidJar,:應用程序:prepareDebugUnitTestDependencies,:應用程序:generateDebugAndroidTestSources,:應用程序:compileDebugSources,:應用程序:compileDebugUnitTestSources,:應用程序:compileDebugAndroidTestSources,:交通:generateDebugSources,:交通:generateDebugAndroidTestSources,:交通:mockableAndroidJar,:交通:prepareDebugUnitTestDependencies,:交通:compileDebugSources,:交通:compileDebugAndroidTestSources,:交通:compileDebugUnitTestSources]

錯誤:LAMBDA從jar文件來需要在classpath他們的接口進行編譯,未知的接口是io.socket.emitter.Emitter $ Listener

錯誤:來自jar文件的Lambda需要它們在要編譯的類路徑上的接口,未知接口是io.reactivex.functions.Predicate

錯誤:來自jar文件的Lambda需要它們在要編譯的類路徑上的接口,未知接口io.reactivex.functions.Consumer

錯誤:LAMBDA從jar文件未來需要他們在classpath接口進行編譯,未知的接口io.socket.emitter.Emitter $監聽

錯誤:LAMBDA來自jar文件需要它們的類路徑上的接口進行編譯,未知的接口是io.socket.emitter.Emitter $ Listener

錯誤:LAMBDA從jar文件來需要在classpath他們的接口被編譯的,未知的接口io.reactivex.FlowableOnSubscribe

錯誤:LAMBDA從jar文件來需要在classpath他們的接口進行編譯,未知接口io.socket.emitter.Emitter $監聽

錯誤:LAMBDA從jar文件未來需要他們在classpath接口進行編譯,未知的接口io.socket.emitter.Emitter $監聽

錯誤:執行失敗的任務':app:transformClassesWithPreJackPackagedLibrariesForDebug' 。

com.android.build.api.transform.TransformException: com.android.builder.core.JackToolchain$ToolchainException: Jack compilation exception

關注我的build.gradle

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
    applicationId "com.communicator" 
    minSdkVersion 15 
    targetSdkVersion 25 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    vectorDrawables.useSupportLibrary = true 
    jackOptions { 
     enabled true 
    } 

    } 
    buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
    } 
    configurations.all { 
    resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9' 
    } 
    compileOptions { 
    sourceCompatibility JavaVersion.VERSION_1_8 
    targetCompatibility JavaVersion.VERSION_1_8 
    } 
} 

ext { 
    rxlifecycleVersion = '2.0.1' 
    icepickVersion = '3.2.0' 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
    exclude group: 'com.android.support', module: 'support-annotations' 
    }) 

    compile 'io.reactivex.rxjava2:rxjava:2.0.7' 
    compile "com.trello.rxlifecycle2:rxlifecycle:$rxlifecycleVersion" 
    compile "com.trello.rxlifecycle2:rxlifecycle-android:$rxlifecycleVersion" 
    compile "com.trello.rxlifecycle2:rxlifecycle-components:$rxlifecycleVersion" 

    compile "frankiesardo:icepick:$icepickVersion" 
    provided "frankiesardo:icepick-processor:$icepickVersion" 

    compile project(path: ':transport') 
    compile 'com.android.support:appcompat-v7:25.3.1' 
    compile 'com.android.support.constraint:constraint-layout:1.0.1' 
    compile 'com.android.support:support-v4:25.3.1' 
    compile 'com.android.support:design:25.3.1' 
    testCompile 'junit:junit:4.12' 
} 

以下順序工作。

  1. 將minSdkVersion更改爲25.同步並生成項目。
  2. 再次將minSdkVersion更改爲15。同步並製作項目。

但是這使得編譯速度非常慢,我需要在每次更改代碼後都遵循這個順序。有更好的選擇嗎?

回答

0

它與android-gradle支持有關。 你可能不得不使用新版本的android gradle插件,但截至目前有點棘手。

我使用gradle-android插件版本2.4解決了同樣的問題。0-alpha7

中的build.gradle我說:

classpath 'com.android.tools.build:gradle:2.4.0-alpha7' 

然而,這是不夠的,一個環境變量也需要(因爲它是一個alpha版本),見this answer

0

更改gradle android:

classpath 'com.android.tools.build:gradle:2.4.0-' 
相關問題