Android 安装 PhoneGap,执行命令“ant”时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21985542/
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
Installing PhoneGap, error executing command 'ant'
提问by Arko Elsenaar
When installing PhoneGap via nodeJS i got an error when trying to run my app (installing phonegap and creating the app worked):
通过 nodeJS 安装 PhoneGap 时,我在尝试运行我的应用程序时遇到错误(安装 phonegap 并创建应用程序有效):
C:\Users\arko\my-app>phonegap run android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[error] An error occured during creation of android sub-project.
C:\Users\arko\.cordova\lib\android\cordova.3.0\bin\node_modules\q\q.js:126
throw e;
^
Error: ERROR : executing command 'ant', make sure you have ant installed and add
ed to your path.
at C:\Users\arko\.cordova\lib\android\cordova.3.0\bin\lib\check_reqs.js:47
:27
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Socket.<anonymous> (child_process.js:956:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:465:12)
So I noticed I never had ANT installed, so I did. I followed this tutorial: http://cleancodedevelopment-qualityseal.blogspot.nl/2012/11/how-to-install-phonegap-for-android.htmland done everything it said.
所以我注意到我从来没有安装过 ANT,所以我安装了。我遵循了本教程:http: //cleancodedevelopment-qualityseal.blogspot.nl/2012/11/how-to-install-phonegap-for-android.html并完成了它所说的一切。
The part it says you have to add stuff to the Path variable, it said just add this: %ANT_HOME%\bin; however my Path ended with this: C:\Program Files\Windows Live\Shared - so I added this to it: ;%ANT_HOME%\bin;
它说你必须向 Path 变量添加内容的部分,它说只需添加: %ANT_HOME%\bin; 但是我的路径以这个结尾:C:\Program Files\Windows Live\Shared - 所以我添加了这个:;%ANT_HOME%\bin;
Tried to run the android app again, and got the same error. I ran it with this command:
尝试再次运行 android 应用程序,并得到相同的错误。我用这个命令运行它:
phonegap run android
What am I doing wrong?
我究竟做错了什么?
Thanks!
谢谢!
回答by hardvin
Probably you have a new version of cordova, i saw that in a partner machine was installed the cordova version 3.5.0 and in my machine it was installed the 3.4.0 version, maybe the ant version is incompatible with the new version of cordova (He and i has the ant version 1.9.4) .
可能你有一个新版本的cordova,我看到在合作伙伴机器上安装了cordova 3.5.0版本,而在我的机器上安装了3.4.0版本,可能是ant版本与新版本cordova不兼容(他和我有蚂蚁版本 1.9.4)。
Try install a old version of cordova with this command in the node.js console:
尝试在 node.js 控制台中使用以下命令安装旧版本的cordova:
npm install -g [email protected]
and run the command again.
并再次运行该命令。
Other cause: Verify that your Path Variables are configured correctly..
其他原因:验证您的路径变量配置正确..
My english is not pretty good, but i hope help you to solve the problem.
我的英语不是很好,但我希望能帮助你解决问题。
回答by Somwang Souksavatd
Variable: ANDROID_HOME Value: C:\Development\adt-bundle\sdk
Variable: ANT_HOME Value: C:\Development\apache-ant-1.9.2
Variable: JAVA_HOME Value: C:\Program Files\Java\jdk1.6.0_45
then define system paths
然后定义系统路径
%JAVA_HOME%\bin;%ANT_HOME%\bin;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools;
reboot your computer
重启你的电脑
Cannot get ant installed properly for phonegap using eclipse and windows 8
回答by Krishna Patel
Set the path for ant
in your system variables, and use that variable path in your user variables.
After setting both, restart your computer so they take effect.
ant
在系统变量中设置路径,并在用户变量中使用该变量路径。两者都设置好后,重启电脑,让它们生效。
User variables:
用户变量:
PATH = %ANT_HOME%/bin
System variables:
系统变量:
ANT_HOME = c:\your directory
such as
如
ANT_HOME = C:\ant
回答by brianary
Double check what you set ANT_HOME to, you can do that by opening a "command prompt" (Start -> Run -> CMD) and type echo %ANT_HOME%
仔细检查您将 ANT_HOME 设置为什么,您可以通过打开“命令提示符”(开始 -> 运行 -> CMD)并键入 echo %ANT_HOME%
Check if this is the correct directory that you have ANT installed into, otherwise set it. (The URL you linked to tells you how).
检查这是否是您安装 ANT 的正确目录,否则设置它。(您链接到的 URL 告诉您如何操作)。
You can verify the ANT "installation" by typeing ant -version
in a "command prompt" window.
您可以通过ant -version
在“命令提示符”窗口中键入来验证 ANT“安装” 。
回答by user1826240
?Did you create JAVA_HOME and ANT_HOME variables? ?Did you also add to the PATH?
?您是否创建了 JAVA_HOME 和 ANT_HOME 变量??您是否也添加到 PATH 中?
回答by Ricardo Ferreira
Instead of creating the ant variable ANT_HOME
, just insert the absolute path in your windows system variable PATH
like this:
而不是创建 ant 变量ANT_HOME
,只需PATH
像这样在 Windows 系统变量中插入绝对路径:
c:\yourDirectory\ant\bin;
Then it should work/run fine!
然后它应该可以正常工作/运行!