我注意到这个问题已被某人广泛询问并“解决”,但是我无法在我的机器上使用它。
我正在使用cordova来构建Android应用程序-一旦我运行“ cordova build android”,我就会得到以下输出:
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk-9.0.1
studio
BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '9.0.1'.
* 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
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '9.0.1'.
* Try:
Run with --stacktrace option to get the stack trace.
* Get more help at https://help.gradle.org
大-v:
------------------------------------------------------------
Gradle 4.8.1
------------------------------------------------------------
Build time: 2018-06-21 07:53:06 UTC
Revision: 0abdea078047b12df42e7750ccba34d69b516a22
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM: 9.0.1 (Oracle Corporation 9.0.1+11)
OS: Windows 10 10.0 amd64
Java版本:
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
在我看到的一些帖子中,他们有一个非常老的Gradle版本,而我的是最新版本。
对此有直接解决办法吗?
答案 0 :(得分:0)
这是Cordova未能正确检测到Java版本的错误,因为它期望其版本为1.x(即1.9)而不是9。
无论如何,不支持Java 9,您必须按照Android的要求将JDK降级为Java 8。