运行./gradlew clean build
时收到以下消息:
> Task :compileKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/usr/lib/jvm/java-8-openjdk-amd64/jre' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
我有JDK,JAVA_HOME
设置正确,update-alternatives
也是如此。
# java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.16.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
# update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/default-java/bin/java 1100 auto mode
1 /usr/lib/jvm/default-java/bin/java 1100 manual mode
2 /usr/lib/jvm/java-8-openjdk-amd64/bin/java 1 manual mode
3 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
在这里启用了堆栈跟踪的gradle构建:
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileKotlin'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:74)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph.execute(DefaultTaskExecutionGraph.java:143)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:40)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:40)
at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:24)
at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:46)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:49)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:40)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:33)
at org.gradle.initialization.DefaultGradleLauncher$ExecuteTasks.run(DefaultGradleLauncher.java:355)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.initialization.DefaultGradleLauncher.runTasks(DefaultGradleLauncher.java:219)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:124)
at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:77)
at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:74)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:154)
at org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:38)
at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:96)
at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:74)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.run(RunAsBuildOperationBuildActionRunner.java:50)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:45)
at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$1.transform(InProcessBuildActionExecuter.java:47)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$1.transform(InProcessBuildActionExecuter.java:44)
at org.gradle.composite.internal.DefaultRootBuildState.run(DefaultRootBuildState.java:79)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:44)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)
at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:80)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:53)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:62)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:34)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:59)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:31)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:59)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:44)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:46)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:81)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.api.GradleException: Kotlin could not find the required JDK tools in the Java installation '/usr/lib/jvm/java-8-openjdk-amd64/jre' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
at org.jetbrains.kotlin.gradle.tasks.JarSearchingUtilKt.findToolsJar(jarSearchingUtil.kt:95)
at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:255)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99)
... 111 more
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.util.Context
at org.jetbrains.kotlin.gradle.tasks.JarSearchingUtilKt.findToolsJar(jarSearchingUtil.kt:92)
... 124 more
因此,据我所知,由于配置的路径是到JDK,因此在搜索tools.jar
下的/usr/lib/jvm/default-java/lib
时失败了。
我的gradle.build
-以防万一:
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.11'
}
ext {
ktorVersion = "1.1.2"
}
group 'com.example'
version '1.0-SNAPSHOT'
repositories {
jcenter()
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "io.ktor:ktor-server-netty:$ktorVersion"
implementation "io.ktor:ktor-jackson:$ktorVersion"
implementation "io.ktor:ktor-freemarker:$ktorVersion"
implementation "io.ktor:ktor-auth:$ktorVersion"
implementation "ch.qos.logback:logback-classic:1.2.3"
implementation 'io.github.microutils:kotlin-logging:1.6.22'
implementation 'org.koin:koin-ktor:2.0.0-beta-3'
implementation 'org.litote.kmongo:kmongo-coroutine:3.10.0'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
我真的很茫然,不胜感激。
如果需要更多信息,请告诉我,我会尽力提供。
答案 0 :(得分:25)
android studio 也提供 jdk。 如果你指定jdk如下,它会成功
export PATH=$PATH:/Applications/"Android Studio.app"/Contents/jre/jdk/Contents/Home/bin
export JAVA_HOME=/Applications/"Android Studio.app"/Contents/jre/jdk/Contents/Home
答案 1 :(得分:22)
在 MacOS 更新到 Big Sur 之后,我遇到了与上面 Tom Aranda 相同的问题。 经过进一步调查,我遇到了 this SO post,这让我找到了 this radar。我不喜欢按照 Tom 的回答删除 JRE,因此我已经使用其他帖子中的详细信息解决了我自己的安装问题.....
我之前对 JAVA_HOME
的声明是在 ~/.zshrc
as
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
但 Big Sur 似乎也将默认 JRE 版本更新为 1.8。所以我的 JAVA_HOME 需要更精确的过滤。
% /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
1.8.251.08 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
1.8.0_241 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
我现在导出为
export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_241`
现在这并不理想,因为它会在我下次更新 JDK 时中断。
根据雷达和其他 SO 帖子中的详细信息,我还需要确保在再次导出之前未设置任何现有导出的 JAVA_HOME,因此我在 ~/.zshrc
中的新条目现在已成为
unset JAVA_HOME;export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_241`
终端重新启动后,我之前失败的 gradlew
命令现在可以像以前一样运行了。
对我来说,这感觉像是一个更好的解决方案,因为我没有删除任何库,而且我只从我自己的终端命令中影响了 java home。很遗憾我需要指定精确的版本,因为这会在将来的某个时候中断。
答案 2 :(得分:15)
我在MacOS(Big Sur)中解决了类似的问题。就我而言,我正在运行一个React Native项目,并尝试构建到Android时遇到以下错误:
* What went wrong:
Execution failed for task ':bugsnag_react-native:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home' used by G
radle. Make sure Gradle is running on a JDK, not JRE.
我跟随this article在MacOS上卸载了JRE。稍作修改以使该过程可逆,请按以下步骤操作:
cd /Library/Internet\ Plug-Ins/
mv JavaAppletPlugin.plugin DELETED-JavaAppletPlugin.plugin
cd /Library/PreferencePanes/
mv JavaControlPanel.prefPane DELETED-JavaControlPanel.prefPane
收到Permission denied
后,请在命令前使用sudo
。
然后我清除了Gradle文件夹。我不知道这是否有必要,但是对我有用:
rm -rf ~/.gradle
最后,我重建了项目(react-native run-android
),一切正常。
我不确定删除JRE是最好的解决方案,因为您可能需要JRE做其他事情,但是我没有注意到有任何不良影响。另外,似乎我已经安装了JDK,对于所有Mac用户来说可能并非如此。
由于在MacOS上Stack Overflow上没有解决该问题的好答案,因此我想将解决方案发布在这里。
答案 3 :(得分:3)
根据提供的数据,确定java
在环境路径中。但是,它不能确认JAVA_HOME是否设置为JDK目录。您确定JAVA_HOME
未被设置为/usr/lib/jvm/java-8-openjdk-amd64/jre
或/usr/lib/jvm/java-8-openjdk-amd64
而不是/usr/lib/jvm/default-java
吗?
因为,如果设置了JAVA_HOME
,则gradlew将忽略PATH中的java
二进制文件并执行$JAVA_HOME/bin/java
,而System.getProperty("java.home")
将在登录的value
中可用此异常(请参见jarSearchingUtil.Kt)
否则,您可以尝试直接在 gradlew 文件中声明JAVA_HOME
答案 4 :(得分:2)
D3
它设置为> Kotlin could not find the required JDK tools in the Java installation '/usr/lib/jvm/java-8-openjdk-amd64/jre' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
。
应将JAVA_HOME设置为/usr/lib/jvm/java-8-openjdk-amd64/jre
如果您的操作系统是Ubuntu,请通过/usr/lib/jvm/java-8-openjdk-amd64/
让suer安装openjdk jdk
sudo apt-get install openjdk-8-jdk
将安装jre,而不是jdk
答案 5 :(得分:2)
我通过删除某种版本的java解决了这个问题。
我有两种Java,如下图。
但是我在执行 ./gradlew clean assembleRelease
时失败了,这提醒我可能是我使用的 JDK 的问题。
然后,我发现2种java的主页内容各不相同。左边是我从 Oracle 下载的那个。
所以,我试图通过删除第一个 java 的家来修复它。(首先压缩文件夹以进行复制)。
它的工作!
答案 6 :(得分:2)
在 BIG SUR 上,遇到此错误的人可能已经安装了自定义 Java。使用以下命令删除它
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencesPanes/JavaControlPanel.prefPane
sudo rm -fr ~/Library/Application\ Support/Oracle/Java
在那之后取消设置您拥有的任何自定义 JAVA_HOME 并将其从您的 shell 中删除,它应该会重新开始工作。
答案 7 :(得分:1)
我遇到了完全相同的问题。我通过安装const puppeteer = require('Puppeteer');
const fs = require('fs');
const downloader = require('Image-downloader');
Function GetlargestImagesFromSrcset(SrcSet) {
const SplitedSrcs = srcset.split(',');
const ImgSrc = SplitedSrcs[SplitedSrcs.length - 1].split(' ')[0];
return ImgSrc;
}
async function GetImageFromPage(Url) {
const Browser = await puppeteer.Launch();
const page = await brwoser.newpage();
await page.goto(url);
const ImageSrcSets = await page.evaluate(() => {
const imgs = Array.from(document.querySelectorAll('Article img'));
const srcSetAttribute = imgs.map(i => i.getAttribute('Srcset'));
return srcSetAttribute;
})
const imgUrls = ImageSrcSets.map(srcSet => GetlargestImagesFromSrcset(SrcSet));
await browser.Close();
return imgUrls;
}
async Function main() {
//
if (!fs.existSync('./result')) {
fs.mkdirSync('./result');
}
const images = await GetImageFromPage('')
Console.log(images);
Main();
```
解决了它。我的机器正在运行OpenJDK 8 JDK
,所以这是我的安装命令
centos
。
我从vscode docs中学到了两个不同的Java软件包,即Java Runtime Environment(JRE)和Java Development Kit(JDK)。 JRE用于运行Java程序,而JDK用于开发Java应用程序。我只安装了JRE,但没有安装JDK。安装JDK后,我的构建成功运行了
答案 8 :(得分:0)
在 open jdk 8 中遇到这个问题,切换到 open jdk 11 为我解决了。
export JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64/"
答案 9 :(得分:0)
它给了我错误 FAILURE:构建失败,出现异常。 * 出了什么问题:任务 ':app:compileDebugKotlin' 执行失败。 > Kotlin 在 Gradle 使用的 Java 安装“C:\Program Files\Java\jre1.8.0_281”中找不到所需的 JDK 工具。确保 Gradle 在 JDK 上运行,而不是 JRE
我通过下载并安装 Java SE Development Kit 8 解决了这个问题 并在路径中创建安装文件夹后 C:\Program Files\Java\jdk1.8.0_281
答案 10 :(得分:0)
如果您使用的是 Mac,诀窍是从 Oracle 安装 JDK,他们现在正在更改许可政策,因此显然它不再完全免费用于商业用途。 也就是说,安装后,您会在 MAC 上找到 JDK:“/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home” 如果您转到 gradle.properties,您可以插入以下行: “org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home” 进入文件。 重启Android studio,选择Android设备,应该就可以了。 有趣的是,如果您转到 Finder,并导航到该文件夹,然后将该文件夹拖到 textedit 或 vim 中的 gradle.properties 文件中,路径就会神奇地显示出来。我已经使用 Mac 超过 10 年了,直到在这次新的 Android Studio 尝试中才发现这一点。 它对我有用。感谢 Stack Overflow 社区,它是任何应用程序开发人员工具包的重要组成部分。
答案 11 :(得分:0)
就我而言,我的实验室有 windows 7、visual studio、android studio 和 flutter 环境。 当我开始调试时,发生了同样的问题。
为了解决这个问题,
首先,通过 Visual Studio 上的扩展安装 Java 扩展包。
第二,遵循 Java 扩展包,在配置运行屏幕上需要 JDK 11。
三、下载安装JDK(java开发工具包)11
第四,安装时必须检查安装过程中设置的路径。也许,它没有自动设置路径。你必须检查制作路径。
如果设置和安装正确,它会自动出现在系统环境变量中作为 JAVA_HOME 名称。不是用户变量。
再次运行主飞镖。您可以正确看到模拟器
答案 12 :(得分:-1)
使用您的jdk版本将其添加到gradle.properties
org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_102