Cordova 无法添加 Android 失败,退出代码为 ENOENT
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23422961/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cordova cannot add Android failed with exit code ENOENT
提问by Bar?? Akkurt
I am trying to create an Android project with Cordova, however i am getting an ENOENT error although i followed the tutorial step by step very carefully, this is getting me angry.
First this is the screenshot of the error:
Here are information about my software and hardware/os:
我正在尝试使用 Cordova 创建一个 Android 项目,但是我收到了一个 ENOENT 错误,尽管我非常小心地一步一步地遵循了教程,这让我很生气。首先这是错误的屏幕截图:
以下是有关我的软件和硬件/操作系统的信息:
Hardware and OS:
硬件和操作系统:
- Intel(R) Core(TM) i5-3230M CPU @ 2.60 GHz 2.60GHz
- 4 GB RAM
- 64 bit operating system, x 64 based processor
- Windows 8
- Intel(R) Core(TM) i5-3230M CPU @ 2.60 GHz 2.60GHz
- 4 GB 内存
- 64 位操作系统,基于 x 64 的处理器
- 视窗 8
Software:Here are some of the outputs of my command line for the related software.
软件:以下是我的相关软件命令行的一些输出。
- $ npm -version
- Output: 1.4.8
- $ cordova -version
- Output: 3.4.1-0.1.0
- $ ant -version
- Output: Apache Ant(TM) Version 1.9.3 compiled on December 23 2013
- $ java -version
- $ npm -version
- 输出:1.4.8
- $cordova -version
- 输出:3.4.1-0.1.0
- $ ant -version
- 输出:2013 年 12 月 23 日编译的 Apache Ant(TM) 版本 1.9.3
- $ java -version
- $ adb version
- Output: Android Debug Bridge version 1.0.31
- $ adb 版本
- 输出:Android Debug Bridge 版本 1.0.31
Here are some of my system variables:
这是我的一些系统变量:
- ANDROID_HOME: C:\adt-bundle-windows-x86_64-20140321\sdk
- ANT_HOME: C:\apache-ant-1.9.3
- JAVA_HOME: C:\Program Files\Java\jdk1.8.0_05
- CLASSPATH: %JAVA_HOME%\jre\lib
PATH: %JAVA_HOME%\bin;C:\app\barisa\product\11.2.0\dbhome_1\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;%ANT_HOME%\bin;C:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools;C:\adt-bundle-windows-x86_64-20140321\sdk\tools;C:\Program Files\nodejs\
Note: I copied the tools.jar from jdk/lib to jre/lib after some research on the internet. Not working.
Note 2: I give the command "cd C:\Users\barisa.cordova\lib\android\cordova\3.4.0\bin" There is a check_reqs file in that folder. However if i type $ chek_reqs in the command line it says "check_reqs is not recognized as an internal or external command ...."
Note 3: I opened command propmt (cmd) by right click -> run as administrator What should i do?
- ANDROID_HOME:C:\adt-bundle-windows-x86_64-20140321\sdk
- ANT_HOME: C:\apache-ant-1.9.3
- JAVA_HOME: C:\Program Files\Java\jdk1.8.0_05
- 类路径:%JAVA_HOME%\jre\lib
路径:%JAVA_HOME%\bin;C:\app\barisa\product\11.2.0\dbhome_1\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client \;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL ;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel \Intel(R) Management Engine Components\IPT;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;c :\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\ Binn\;C:\Program Files (x86)\Windows Kits\8.0\Windows 性能工具包\;C:\Program Files (x86)\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files ( x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools \Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\ VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C: \Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn \;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\ Microsoft SQL Server\110\DTS\Binn\;%ANT_HOME%\bin;C:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools;C:\adt-bundle-windows-x86_64-20140321\sdk \tools;C:\Program Files\nodejs\
注意:我在网上查了一些资料后,将tools.jar从jdk/lib复制到jre/lib。不工作。
注2:我给命令“cd C:\Users\barisa.cordova\lib\android\cordova\3.4.0\bin”在那个文件夹中有一个check_reqs文件。但是,如果我在命令行中键入 $ chek_reqs,它会显示“check_reqs 未被识别为内部或外部命令......”
注 3:我通过右键单击打开命令 propmt (cmd) -> 以管理员身份运行我该怎么办?
Extra information with -d flag:
带有 -d 标志的额外信息:
Update
更新
I cleaned .cordova and reinstalled it and now, i am getting this error:
我清理了 .cordova 并重新安装了它,现在,我收到此错误:
My variables are defined as indicated above.
我的变量定义如上所示。
回答by suraj mahajan
If you are sure of yours paths try to type android in cmd if it says: 'xcopy' was not recognized.
如果您确定自己的路径,请尝试在 cmd 中键入 android,如果它显示:“xcopy”未被识别。
then add to your path:
然后添加到您的路径:
%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;
In certain cases, don't forget to reboot the PC.
在某些情况下,不要忘记重新启动 PC。
回答by Pranita Patil
In my case I just needed to add "C:\Windows\System32" to my windows path.
就我而言,我只需要将“C:\Windows\System32”添加到我的 Windows 路径中。
回答by SuperTed
I had a similar issue when trying ionic platform add android.
我在尝试 ionic platform add android 时遇到了类似的问题。
result;
partial build with ENOENT error titled "cordova-plugin-console" on the same child process as mentioned above superspawn.js
结果; 带有 ENOENT 错误标题的部分构建"cordova-plugin-console" on the same child process as mentioned above superspawn.js
After trying reinstalling etc.. without resolution I changed my path variables around. ANDROID_HOME was placed in user variables --
在尝试重新安装等之后......没有解决我改变了我的路径变量。ANDROID_HOME 被放置在用户变量中——
C:\Users\XXXXXX\AppData\Local\Android\android-sdk
C:\Users\XXXXXX\AppData\Local\Android\android-sdk
PATH was updated in the system variables to remove previous entries for SDK and added at the end;
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Windows\System32;C:\Users\XXXXXX\Node\;C:\Users\XXXXX\AppData\Local\Android\android-sdk\tools;C:\Users\XXXXXX\AppData\Local\Android\android-sdk\platform-tools;
系统变量中的 PATH 已更新,以删除 SDK 的先前条目并在末尾添加;
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Windows\System32;C:\Users\XXXXXX\Node\;C:\Users\XXXXX\AppData\Local\Android\android-sdk\tools;C:\Users\XXXXXX\AppData\Local\Android\android-sdk\platform-tools;
Restart pc, tested with new app
ionic start <new folder> tabs
cd to the folder created,
test it runs with
ionic serve --lab
exit with q then try to add the platform.
ionic platform add android
重启电脑,用新的应用ionic start <new folder> tabs
cd测试
到创建的文件夹,ionic serve --lab
用 q 退出测试它运行,
然后尝试添加平台。
ionic platform add android
now it works..
现在它起作用了..
Please note********* now when i run 'android' in the CMD from my user dir...
C:\Users\XXXXX>android
请注意****** 现在,当我从我的用户目录在 CMD 中运行“android”...
C:\Users\XXXXX>android
i do not see the xcopy not found displayed to my screen. android SDK manager always loaded before and still now after i changed my paths.
我没有看到 xcopy not found 显示在我的屏幕上。android SDK 管理器总是在我更改路径之前和现在加载。
Hope this helps p.s I run these cmds from my user acc which is not the admin acc as i never log in as or use my pc as an administrator.
希望这有助于 ps 我从我的用户 acc 运行这些 cmds,这不是管理员 acc,因为我从来没有以管理员身份登录或使用我的电脑。
回答by mattu
In my case problem was user variable TEMP. There were two folders.
在我的情况下,问题是用户变量TEMP。有两个文件夹。
Not working TEMP -path:
不工作 TEMP -path:
%USERPROFILE%\AppData\Local\Temp;C:\php
Working TEMP -path:
工作 TEMP 路径:
%USERPROFILE%\AppData\Local\Temp
After this everything worked fine!
在此之后一切正常!
回答by Ana
Make sure that if you created PATH as a system variable, you should run Command Prompt as administrator.
确保如果您将 PATH 创建为系统变量,则应以管理员身份运行命令提示符。
I created PATH as a user variable, and would get the same error when tryin to run as administrator.
我创建了 PATH 作为用户变量,并且在尝试以管理员身份运行时会得到相同的错误。
回答by Eymen Elkum
Try to follow these steps:
尝试按照以下步骤操作:
- run the command: npm uninstall cordova -g
- delete the folder: C:\Users\your-name\.cordova
- reinstall the cordova: npm install -g cordova
- now go to the project folder and try again: cordova platform add android
- 运行命令: npm uninstall cordova -g
- 删除文件夹:C:\Users\your-name\.cordova
- 重新安装cordova:npm install -g cordova
- 现在转到项目文件夹并重试:cordova platform add android
回答by ShinyJos
I had this exact same error days ago with cordova version 3.1.Go to directory path C:\Program Files\nodejs and then install your cordova.Sometimes cordova cannot connect to the right path of npm due to conflict.Then create your project and add platform android.Hope this solution works for you too.
我几天前使用cordova 3.1版遇到了完全相同的错误。转到目录路径C:\ Program Files \ nodejs,然后安装你的cordova。有时由于冲突,cordova无法连接到npm的正确路径。然后创建你的项目并添加android 平台。希望此解决方案也适用于您。
回答by Bhavikkumar
I just run cmd with as Administrator and execute 'cordova platform add android' command and now work fine.
我只是以管理员身份运行 cmd 并执行“cordova platform add android”命令,现在工作正常。