我已经看到了很多关于此的查询。但是这些都无法解决我的问题。我正在尝试构建一个Cordova Android应用程序。但是Cordova要求总是失败,因为它找不到JAVA_HOME。我收到的错误在下面
C:\Android-Dev\WorkSpace\myTFS>cordova requirements
Android Studio project detected
Requirements check results for android:
**Java JDK: not installed
Failed to run "javac -version", make sure that you have a JDK installed.
You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.
Your JAVA_HOME is invalid: C:\Program Files\Java\jdk1.8.0_171**
Android SDK: installed true
Android target: not installed
cmd: Command failed with exit code ENOENT
Gradle: not installed
Cannot read property 'toString' of null
(node:4220) UnhandledPromiseRejectionWarning: CordovaError: Some of requirements check failed
at C:\Users\SAHAA2\AppData\Roaming\npm\node_modules\cordova\src\cli.js:414:27
at _fulfilled (C:\Users\SAHAA2\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54)
at C:\Users\SAHAA2\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30
at Promise.promise.promiseDispatch (C:\Users\SAHAA2\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:749:13)
at C:\Users\SAHAA2\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:557:44
at flush (C:\Users\SAHAA2\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:108:17)
at process._tickCallback (internal/process/next_tick.js:61:11)
at Function.Module.runMain (internal/modules/cjs/loader.js:746:11)
at startup (internal/bootstrap/node.js:240:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:564:3)
(node:4220) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise
which was not handled with .catch(). (rejection id: 1)
(node:4220) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero
exit code.
下面是我的JAVA主页和路径变量设置。我知道很多人都要求在PATH变量中提供bin文件夹的路径。但是它仍然无法正常工作。下面是我的系统变量
C:\Android-Dev\WorkSpace\myTFS>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_171
C:\Android-Dev\WorkSpace\myTFS>echo %path%
C:\Program Files\Java\jdk1.8.0_171\bin;C:\Program Files\nodejs\;C:\Android-Dev\SDK\platform-tools;C:\Android-Dev\SDK\tools;C:\Program Files\Android\Android Studio\gradle\gradle-4.4\bin;C:\User
s\SAHAA2\AppData\Roaming\npm
这与访问问题有关吗? 无法运行“ javac -version”,请确保您已安装JDK。
任何帮助将不胜感激。我会避免像很多人以前所提出的那样再次提出这个问题,但是似乎没有任何工作对我有用。因此,再次提出相同的问题。任何需要更多详细信息的人请告诉我
答案 0 :(得分:0)
这可能是由于JAVA_HOME路径中的空间不足。将C:\Program Files\Java\jdk1. 8.0_171
替换为C:\Progra~1\Java\jdk1. 8.0_171