3

我在 Android Studio 2.1.3 (Windows 7) (plugin) 中配置了我的项目 (Module:app classpath 'com.android.tools.build:gradle:2.1.3')

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
    }

    dependencies {
       classpath 'io.fabric.tools:gradle:1.+'
       classpath 'me.tatarka:gradle-retrolambda:3.3.1'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'me.tatarka.retrolambda'

retrolambda {
    jdk System.getenv("JAVA8_HOME")
    oldJdk System.getenv("JAVA7_HOME")
    javaVersion JavaVersion.VERSION_1_7
}
android {    
    compileSdkVersion 23
    buildToolsVersion '24.0.2'

    defaultConfig {
        applicationId "com.enterprise"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        signingConfig signingConfigs.config        
        jackOptions {
            enabled true
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
....

我得到了

Error:A problem occurred configuring project ':app'.

我使用 Facebook 和 Twitter (fabric) 依赖项。

我删除apply plugin: 'me.tatarka.retrolambda'了它运行正常但没有retrolambda。

我试过:

我在 IDE 日志中得到了这个

Caused by: org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':app'.
    at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61)
.....
Caused by: java.lang.NullPointerException
    at me.tatarka.RetrolambdaPluginAndroid.configureCompileJavaTask(RetrolambdaPluginAndroid.groovy:74)
    at me.tatarka.RetrolambdaPluginAndroid.access$3(RetrolambdaPluginAndroid.groovy)
    at me.tatarka.RetrolambdaPluginAndroid$_apply_closure5.doCall(RetrolambdaPluginAndroid.groovy:64)
    at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:67)
    at org.gradle.listener.ActionBroadcast.execute(ActionBroadcast.java:39)
    at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:165)
4

1 回答 1

2

我遇到了同样的问题,将 Retrolambda更新到 3.5.0 版。

在你的根 build.gradle 中输入:

buildscript {
  repositories {
    ...
    mavenCentral()
  }
  dependencies {
    ...
    classpath "com.android.tools.build:gradle:2.2.3"
     classpath 'me.tatarka:gradle-retrolambda:3.5.0'
  }
}

//At the end of the file place this:
apply plugin: 'me.tatarka.retrolambda'

在您的模块应用程序 build.gradle 中输入:

apply plugin: 'com.android.application'
android {
    ...
    defaultConfig {
        ...
        jackOptions {
            enabled true
            jackInProcess false
        }
    }
}

compileOptions {
    targetCompatibility JavaVersion.VERSION_1_8
    sourceCompatibility JavaVersion.VERSION_1_8
    incremental false
}

//it needs to translate the Java 8 code we write in the Java 7/ Java 6 bytecode Android understands:
retrolambda {
    jdk System.getenv('JAVA8_HOME')
    oldJdk System.getenv('JAVA7_HOME')
    jvmArgs '-arg1', '-arg2'
    defaultMethods false
   incremental true
}

您可以使用此实用程序查询 Java 安装,询问我们作为输入参数提交的版本的路径。

于 2017-02-28T22:44:35.020 回答