2

今天,我retrolamda-gradle在我的 Android 项目中使用插件。Sync过程没问题,但是当我运行项目时,出现如下错误:

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> When running gradle with java 5, 6 or 7, you must set the path to jdk8, either with property retrolambda.jdk or environment variable JAVA8_HOME

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

2: Task failed with an exception.
-----------
* What went wrong:
A problem was found with the configuration of task ':app:compileRetrolambdaDebug'.
> Directory 'G:\0-RxJava\0-code\RxAnsroidPrj01\app\build\retrolambda\debug' specified for property 'inputDir' does not exist.

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

在我的build.gradle(Project)中,我只是添加classpath依赖项:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'me.tatarka:gradle-retrolambda:3.2.5' // it's what I add
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

在我的build.gradle(module)

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.eldorado.rxansroidprj01"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    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(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
}

PS:我的java家是这样的:JAVA7_HOME=D:\Java\jdk1.7.0_25JAVA8_HOME=D:\Java\jdk1.8.0_91

如果有人能告诉我如何使用,我将不胜感激--stacktrace option。也许会有所帮助!

4

0 回答 0