我在Android Studio 2.1.3(Windows 7)中配置了我的项目(模块: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(结构)依赖。
我删除了apply plugin: 'me.tatarka.retrolambda'
,它运行正常,但没有retrolambda。
我试过了:
classpath 'com.android.tools.build:gradle-experimental:0.7.3'
我在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)
答案 0 :(得分:2)
我遇到了同样的问题,请将Retrolambda更新为3.5.0版。
在你的root 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'
在你的模块app 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
}
您可以使用this utility查询Java安装,询问我们提交的版本的路径作为输入参数。