简体   繁体   English

Gradle 构建失败并出现 Java IOException

[英]Gradle build failing with Java IOException

I'm getting the following error when I'm trying to execute the gradle.bat file, or any gradle command for that matter (eg. gradle -version).当我尝试执行 gradle.bat 文件或任何与此相关的 gradle 命令(例如 gradle -version)时,出现以下错误。

FAILURE: Build failed with an exception.

* What went wrong:
java.io.IOException: The filename, directory name, or volume label syntax is incorrect

Gradle Version: 4.10.2摇篮版本:4.10.2

JDK: "1.8.0_261" JDK:“1.8.0_261”

OS: Windows 10 (x64)操作系统:Windows 10 (x64)

What could have possibly gone wrong?可能出了什么问题?


PS: I have also tried the same with a newer gradle version (6.6.1). PS:我也用较新的 gradle 版本(6.6.1)尝试过同样的方法。 It generated a similar error.它产生了类似的错误。

FAILURE: Build failed with an exception.

* What went wrong:
java.io.IOException: The filename, directory name, or volume label syntax is incorrect

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.UncheckedIOException: java.io.IOException: The filename, directory name, or volume label syntax is incorrect
        at org.gradle.internal.FileUtils.canonicalize(FileUtils.java:204)
        at org.gradle.initialization.BuildLayoutParameters.findGradleUserHomeDir(BuildLayoutParameters.java:51)
        at org.gradle.initialization.BuildLayoutParameters.<init>(BuildLayoutParameters.java:39)
        at org.gradle.launcher.cli.converter.BuildLayoutConverter.defaultValues(BuildLayoutConverter.java:42)
        at org.gradle.launcher.cli.DefaultCommandLineActionFactory$WithLogging.execute(DefaultCommandLineActionFactory.java:205)
        at org.gradle.launcher.Main.doAction(Main.java:35)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:50)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:31)
Caused by: java.io.IOException: The filename, directory name, or volume label syntax is incorrect
        at java.io.WinNTFileSystem.canonicalize0(Native Method)
        at java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:428)
        at java.io.File.getCanonicalPath(File.java:618)
        at java.io.File.getCanonicalFile(File.java:643)
        at org.gradle.internal.FileUtils.canonicalize(FileUtils.java:202)
        ... 13 more

只需在User Variables而不是System Variables下添加 GRADLE_USER_HOME 环境变量即可解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM