2015-09-04 78 views
0

我正在開發一款Android應用程序,我想出了RetroLambda工具,我可以在Android應用程序中使用Lambda表達式(這麼多贏!!)。Android,Gradle:RetroLambda無法正常工作

不幸的是它不工作。我張貼我的Gradle文件的應用程序和整體。請讓我知道我做錯了什麼。非常感謝。

的build.gradle(模塊:APP)

apply plugin: 'com.android.application' 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'com.android.support:appcompat-v7:22.2.1' 
    compile 'com.android.support:support-v4:22.2.1' 
    compile 'com.fasterxml.jackson.core:jackson-core:2.6.0' 
    compile 'com.fasterxml.jackson.core:jackson-databind:2.6.0' 
    compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE' 
    compile 'org.springframework.android:spring-android-core:1.0.1.RELEASE' 
    compile ('org.springframework.android:spring-android-auth:1.0.1.RELEASE'){ 
     exclude group :'org.springframework', module: 'commons-logging' 
     exclude group :'org.springframework', module: 'spring-core' 
     exclude group :'org.springframework', module: 'spring-web' 
    } 
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.6.0' 
    compile 'com.google.android.gms:play-services:7.5.0' 
    compile 'commons-codec:commons-codec:1.9' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'io.reactivex:rxandroid:1.0.1' 
} 




android { 
    compileSdkVersion 22 
    buildToolsVersion "22.0.1" 

    defaultConfig { 
     applicationId "myapp" 
     minSdkVersion 16 
     targetSdkVersion 22 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_7 
     targetCompatibility JavaVersion.VERSION_1_7 
    } 
    productFlavors { 
    } 

    packagingOptions { 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE.txt' 
     exclude 'META-INF/DEPENDENCIES.txt' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE.txt' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/notice.txt' 
     exclude 'META-INF/license.txt' 
     exclude 'META-INF/dependencies.txt' 
     exclude 'META-INF/LGPL2.1' 
    } 

} 

的build.gradle(模塊:項目名稱)

// Top-level build file where you can add configuration options common to all sub-projects/modules. 
apply plugin: 'me.tatarka.retrolambda' 

buildscript { 
    repositories { 
     jcenter() 
     mavenCentral() 

    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:1.2.3' 
     classpath 'me.tatarka:gradle-retrolambda:3.2.2' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
     mavenCentral() 
    } 
} 

錯誤日誌:

Configuration on demand is an incubating feature. 
:app:preBuild UP-TO-DATE 
:app:preDebugBuild UP-TO-DATE 
:app:checkDebugManifest 
:app:preReleaseBuild UP-TO-DATE 
:app:prepareComAndroidSupportAppcompatV72221Library UP-TO-DATE 
:app:prepareComAndroidSupportMediarouterV72200Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportV42221Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServices750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAds750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAppstate750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesBase750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesCast750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesDrive750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesFitness750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesGames750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesGcm750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesIdentity750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesLocation750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesMaps750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesNearby750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesPanorama750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesPlus750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesWallet750Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesWearable750Library UP-TO-DATE 
:app:prepareIoReactivexRxandroid101Library UP-TO-DATE 
:app:prepareDebugDependencies 
:app:compileDebugAidl UP-TO-DATE 
:app:compileDebugRenderscript UP-TO-DATE 
:app:generateDebugBuildConfig UP-TO-DATE 
:app:generateDebugAssets UP-TO-DATE 
:app:mergeDebugAssets UP-TO-DATE 
:app:generateDebugResValues UP-TO-DATE 
:app:generateDebugResources UP-TO-DATE 
:app:mergeDebugResources UP-TO-DATE 
:app:processDebugManifest UP-TO-DATE 
:app:processDebugResources UP-TO-DATE 
:app:generateDebugSources UP-TO-DATE 
:app:processDebugJavaRes UP-TO-DATE 
:app:compileDebugJava 
Note: /home/akshay/AndroidStudioProjects/app/app/src/main/java/myapp/com/app/Service/RestaurantServiceImpl.java uses unchecked or unsafe operations. 
Note: Recompile with -Xlint:unchecked for details. 

:app:compileDebugNdk UP-TO-DATE 
:app:compileDebugSources 
:app:preDexDebug 
:app:dexDebug 
AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","position":{},"original":"UNEXPECTED TOP-LEVEL EXCEPTION:"} 
AGPBI: {"kind":"SIMPLE","text":"com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536","position":{},"original":"com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536"} 
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)","position":{},"original":"\tat com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)"} 
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)","position":{},"original":"\tat com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)"} 
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)","position":{},"original":"\tat com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)"} 
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)","position":{},"original":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)"} 
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)","position":{},"original":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)"} 
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)","position":{},"original":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)"} 
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)","position":{},"original":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)"} 
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:246)","position":{},"original":"\tat com.android.dx.command.dexer.Main.run(Main.java:246)"} 
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)","position":{},"original":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)"} 
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.Main.main(Main.java:106)","position":{},"original":"\tat com.android.dx.command.Main.main(Main.java:106)"} 


FAILED 

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':app:dexDebug'. 
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 2 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

BUILD FAILED 

Total time: 8.888 secs 

我現在運行模擬器。我希望這不是問題。非常感謝。

+1

'compileOptions {} {sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }'? – mbmc

+0

@tibo:我應該改變爲8? –

+0

@tibo:沒有,沒有幫助。 –

回答

0

您可以將該插件應用到應用程序的build.gradle(而不是根項目)中。你應該檢查的另一件事是,你的依賴是否有java 8寫的類。如果是這樣,請注意該插件僅適用於您當前的項目(類),並且與依賴關係中的類無關。如果你想重新調整這些依賴關係,你可以將它們解壓到某個地方並應用該插件。