我发表了以下评论:

./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——版本,我得到以下:

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 /包装/ 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

当前回答

我通过单击文件->项目结构解决了这个问题,然后将JDK位置更改为使用嵌入式JDK(推荐)

其他回答

我也遇到过类似的问题。我删除了这些:

库和缓存从。idea文件夹(YourApp > .idea > ..)和 生成文件夹的内容。 然后重建。

*别忘了先备份你的项目*

我也遇到过同样的问题。升级到gradle 5.0对我来说很有用。

这个链接提供了如何安装gradle 5.0的详细步骤

因为你的包装器版本不支持11+,你可以做一个简单的技巧来欺骗新版本的InteliJ。

  press3x Shift -> type "Switch Boot JDK" -> and change for java 8. 

或者如果你想使用java 11+,你只需将包装器版本更新到4.8+

我在Windows上也遇到了同样的问题。我的gradle配置是使用JDK1.8,但JAVA_HOME配置为使用另一种JDK。

解决方案:

根据gradle中配置的JDK正确设置JAVA_HOME

得到项目文件.. gradle /包装/ gradlewrapper.properties

在这里,您可以将distributionurl的值更改为最新版本。(在docs.gradle.org上找到)