我发表了以下评论:

./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,我正在使用sdkmanager来管理JDK的版本,因此,我将虚拟机的版本更改为1.8。

sdk use java 8.0.222.j9-adpt

在此之后,应用程序将按预期运行。

其他回答

导航到Project/gradle/wrapper/gradle-wrapper。属性,并手动更改distributionUrl为distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip,它工作了,希望这有助于某人。

转到android/gradle/wrapper/gradle-wrapper。并使用最新的gradle版本更新distributionUrl。

访问https://gradle.org/releases/获取最新版本,然后在这里编辑。

https \: / / services.gradle.org/distributions/gradle-7.3.3-all.zip

7.3.3是最新版本。

https \: / / services.gradle.org/distributions/gradle- # latest_gradle-version # -all.zip

在使用cordova构建android时出现此错误

在尝试了这么多不同的事情之后,我能够简单地解决这个问题:

npm install cordova -g   # to upgrade to version 10.0.0

cordova platform rm android
cordova platform add android    # to upgrade to android version 9.0.0

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

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

更新gradle /包装/ gradle-wrapper。属性与以下版本修复它为我:

distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip