Android : Gradle + Retrolambda: Fatal Error: Unable to find package java.lang in classpath or bootclasspath

on Saturday, August 16, 2014


I am trying to integrate gradle-retrolambda in my Android project (following this guide), but I am getting the following error when I run my gradle build



:app:compileDebugJava
Fatal Error: Unable to find package java.lang in classpath or bootclasspath


Stacktrace:


org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJava'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) .... Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details. at org.gradle.api.internal.tasks.compile.jdk6.Jdk6JavaCompiler.execute(Jdk6JavaCompiler.java:47) at org.gradle.api.internal.tasks.compile.jdk6.Jdk6JavaCompiler.execute(Jdk6JavaCompiler.java:38) at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJav ...


I thought it was strange, that it uses the jdk6.Jdk6JavaCompiler although I configured for Java7 compatibility, see gradle build file below.


Gradle version info:



------------------------------------------------------------
Gradle 1.12
------------------------------------------------------------

Build time: 2014-04-29 09:24:31 UTC
Build number: none
Revision: a831fa866d46cbee94e61a09af15f9dd95987421

Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy: 2.2.0
JVM: 1.8.0_11 (Oracle Corporation 25.11-b03)
OS: Linux 3.13.0-32-generic amd64


Java environment paths:



JAVA_HOME=/usr/lib/jvm/java-8-oracle
JAVA8_HOME=/usr/lib/jvm/java-8-oracle
JAVA7_HOME=/usr/lib/jvm/java-7-oracle


Gradle build file:



buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
classpath 'me.tatarka:gradle-retrolambda:2.2.1'
}


}



repositories {
mavenCentral()
flatDir {
dirs 'prebuilt-libs'
}
}

apply plugin: 'com.android.application'

android {
compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
buildToolsVersion "20.0.0"

defaultConfig {
minSdkVersion 19
targetSdkVersion 20
versionCode 1
versionName "1.0"
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}

dependencies {
// gcm (old client library)
compile fileTree(dir: 'libs', include: ['*.jar'])

// auto factory (https://github.com/google/auto/tree/master/factory)
compile 'com.google.auto.factory:auto-factory:0.1-beta1'

// auto value (https://github.com/google/auto/tree/master/value)
compile 'com.google.auto.value:auto-value:1.0-rc1'

// dagger
compile 'com.squareup.dagger:dagger:1.2.0'
provided 'com.squareup.dagger:dagger-compiler:1.2.0'

// butterknife for view injection
compile 'com.jakewharton:butterknife:5.1.1'

// javax annotations (needed for auto generated files)
compile 'javax.annotation:jsr250-api:1.0'

// google guava
compile 'com.google.guava:guava:17.0'

// support library
compile 'com.android.support:support-v4:20+'

// google zxing barcode reader
compile 'com.google.zxing:core:2.3.0'

// progress bar - https://github.com/w9jds/GDK-ProgressBar
compile 'com.w9jds.gdk.progresswidget:library:1.0@aar'

// espresso - https://github.com/JakeWharton/double-espresso
androidTestCompile ('com.jakewharton.espresso:espresso:1.1-r3') {
exclude group: 'com.squareup.dagger'
exclude group: 'com.android.support'
}
}

apply plugin: 'retrolambda'

retrolambda {
jdk System.getenv("JAVA8_HOME")
oldJdk System.getenv("JAVA7_HOME")
javaVersion JavaVersion.VERSION_1_7
}


Just to verify my java8 installation, I created a gradle project in intellij without retrolambda, and that just works fine.


Any idea, what might go wrong here and how to fix it?


0 comments:

Post a Comment