【发布时间】:2019-06-18 20:45:54
【问题描述】:
我发表了以下评论:
./gradlew app:installDebug
只遇到日志:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '11.0.2'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
我的 gradle 版本是 5.1.1:
------------------------------------------------------------
Gradle 5.1.1
------------------------------------------------------------
Build time: 2019-01-10 23:05:02 UTC
Revision: 3c9abb645fb83932c44e8610642393ad62116807
Kotlin DSL: 1.1.1
Kotlin: 1.3.11
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 11.0.2 (Oracle Corporation 11.0.2+9-LTS)
OS: Mac OS X 10.13.6 x86_64
我不确定如何继续(我尝试升级/降级,但到目前为止没有任何效果)。
更新:当我运行 ./gradlew --version 时,我得到以下信息:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '11.0.2'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
我的.../gradle/wrapper/gradle-wrapper.properties 包含以下内容,包括distributionUrl=.../gradle-4.1-rc-1-all.zip:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
【问题讨论】:
-
根据this bug report ,您的 gradle 包装器是否可能较旧?
-
您运行命令 ./gradlew 启动与此特定项目关联的 gradle 版本。不保证项目的版本和你安装的一样(5.1.1)
-
该版本信息是
gradle --version或./gradlew --version的结果吗?基于 Gradle 的项目通常使用wrapper,以便不同的开发人员更容易使用相同的 Gradle 版本来构建项目;这也使构建更加稳定。 -
这是
gradle --version的版本 -
你也可以去你的项目文件夹并打开文件:.../gradle/wrapper/gradle-wrapper.properties 吗?使用简单的文本编辑器打开它。里面的“distributionUrl”应该告诉我们包装器的版本是什么。