gpt4 book ai didi

java - 类路径或引导类路径中的 Gradle + Retrolambda : Fatal Error: Unable to find package java. lang

转载 作者:IT老高 更新时间:2023-10-28 23:36:31 26 4
gpt4 key购买 nike

我正在尝试将 gradle-retrolambda 集成到我的 Android 项目中(遵循 this 指南),但是当我运行我的 gradle build 时出现以下错误

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

堆栈跟踪:

org.gradle.api.tasks.TaskExecutionException:任务“:app:compileDebugJava”执行失败。 在 org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) 在 org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) 在 org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) 在 org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64) 在 org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) 在 org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42) 在 org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) 在 org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)……引起:org.gradle.api.internal.tasks.compile.CompilationFailedException:编译失败;有关详细信息,请参阅编译器错误输出。 在 org.gradle.api.internal.tasks.compile.jdk6.Jdk6JavaCompiler.execute(Jdk6JavaCompiler.java:47) 在 org.gradle.api.internal.tasks.compile.jdk6.Jdk6JavaCompiler.execute(Jdk6JavaCompiler.java:38) 在 org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJav...

我觉得很奇怪,它使用 jdk6.Jdk6JavaCompiler 虽然我配置了 Java7 兼容性,请参阅下面的 gradle 构建文件。

Gradle 版本信息:

------------------------------------------------------------
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 环境路径:

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 构建文件:

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
}

只是为了验证我的 java8 安装,我在 intellij 中创建了一个没有 retrolambda 的 gradle 项目,并且工作正常。

任何想法,这里可能出了什么问题以及如何解决它?

最佳答案

如果你已经设置好了,你就不再需要 retrolambda

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

关于java - 类路径或引导类路径中的 Gradle + Retrolambda : Fatal Error: Unable to find package java. lang,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25335495/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com