英文:
Could not determine java version from '14.0.2'
问题
当我尝试使用 ./gradlew
时,我会遇到以下错误:
构建失败:发生异常。
* 出了什么问题:
无法从 '14.0.2' 确定 Java 版本。
* 尝试:
使用 --stacktrace 选项运行以获取堆栈跟踪信息。使用 --info 或 --debug 选项运行以获取更多日志输出。
我的操作系统是 MacOS Catalina 10.15.6 版本,
我的 Java 版本是 14.0.2,
我的 Gradle 版本是 6.6.1,
我使用 brew install gradle
安装了 Gradle,
我的 JAVA_HOME
变量是 /Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home
,
因某种原因我无法找出问题所在,有任何想法吗?
英文:
When I try to use ./gradlew
I get these errors:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '14.0.2'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
My OS is MacOS Catalina Version 10.15.6,
My Java version is 14.0.2,
My gradle version is 6.6.1,
I installed gradle using brew install gradle
,
and my JAVA_HOME
variable is /Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home
For some reason I cannot figure out the problem, any ideas?
答案1
得分: 8
如果更新开关不起作用,请更新以下属性文件中的值:
cat gradle/wrapper/gradle-wrapper.properties
$ cat gradle/wrapper/gradle-wrapper.properties
#Thu May 03 21:00:01 BST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
然后,再次尝试:
$ ./gradlew build
Downloading https://services.gradle.org/distributions/gradle-6.6.1-all.zip
..........................................................................................................................................
Unzipping /Users/marcellodesales/.gradle/wrapper/dists/gradle-6.6.1-all/ejrtlte9hlw8v6ii20a9584rs/gradle-6.6.1-all.zip 到 /Users/marcellodesales/.gradle/wrapper/dists/gradle-6.6.1-all/ejrtlte9hlw8v6ii20a9584rs
为 /Users/marcellodesales/.gradle/wrapper/dists/gradle-6.6.1-all/ejrtlte9hlw8v6ii20a9584rs/gradle-6.6.1/bin/gradle 设置可执行权限
欢迎使用 Gradle 6.6.1!
以下是此版本的亮点:
- 实验性构建配置缓存
- 处理凭据的内置约定
- Java 编译支持 --release 标志
更多详情请参阅 https://docs.gradle.org/6.6.1/release-notes.html
确保 Java 版本为 14.0.2...
$ java -version
java version "14.0.2" 2020-07-14
Java(TM) SE Runtime Environment (build 14.0.2+12-46)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)
英文:
If updating the switch doesn't work, update the value in the following property file:
cat gradle/wrapper/gradle-wrapper.properties
$ cat gradle/wrapper/gradle-wrapper.properties
#Thu May 03 21:00:01 BST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
Then, try again:
$ ./gradlew build
Downloading https://services.gradle.org/distributions/gradle-6.6.1-all.zip
..........................................................................................................................................
Unzipping /Users/marcellodesales/.gradle/wrapper/dists/gradle-6.6.1-all/ejrtlte9hlw8v6ii20a9584rs/gradle-6.6.1-all.zip to /Users/marcellodesales/.gradle/wrapper/dists/gradle-6.6.1-all/ejrtlte9hlw8v6ii20a9584rs
Set executable permissions for: /Users/marcellodesales/.gradle/wrapper/dists/gradle-6.6.1-all/ejrtlte9hlw8v6ii20a9584rs/gradle-6.6.1/bin/gradle
Welcome to Gradle 6.6.1!
Here are the highlights of this release:
- Experimental build configuration caching
- Built-in conventions for handling credentials
- Java compilation supports --release flag
For more details see https://docs.gradle.org/6.6.1/release-notes.html
Made sure Java version was 14.0.2...
$ java -version
java version "14.0.2" 2020-07-14
Java(TM) SE Runtime Environment (build 14.0.2+12-46)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)
答案2
得分: 2
如果您正在使用gradlew来执行gradle,它可能未使用6.3+(添加了支持)版本的gradle来执行您的构建。您应该尝试使用以下命令升级您的wrapper:
./gradlew wrapper --gradle-version 6.6.1
https://docs.gradle.org/current/userguide/gradle_wrapper.html
英文:
If you are using gradlew to execute gradle it may not be using a 6.3+(where support was added) version of gradle to execute your build. You should try upgrading your wrapper with the command
./gradlew wrapper --gradle-version 6.6.1
https://docs.gradle.org/current/userguide/gradle_wrapper.html
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论