cordova 添加平台 - 执行命令“ant"时出错 [英] cordova add platform - Error executing command 'ant'

查看:35
本文介绍了cordova 添加平台 - 执行命令“ant"时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题已经被问了太多次了……我检查了所有关于 SO 的答案.尝试了我找到的所有组合和解决方案,但到目前为止没有任何效果.

I know that this question has been asked way too many times and.. I checked all ansers on SO. Tried every combination and every solution I found but nothing has worked for me so far.

我已经成功安装了从官方网站下载的cordova,并且我一直在遵循指南.

I've succesfully installed cordova downloading it from the official site and I've been following the Guide.

我首先添加了wp8平台成功.然后我也尝试添加android.

I've added wp8 platform succesfully first. Then I tried to add android as well.

执行命令cordova platform add android后,出现如下错误.

After executing the command cordova platform add android, I got the following error.

Error: executing command 'ant', make sure you have ant installed and added to your path.

这是包含更多详细信息的屏幕截图:

Here's a screenshot with more details:

我已经安装了 ANT,即最后一个 Java JDK 并将所有必要的环境变量添加到我的系统中.

I've installed ANT, the last Java JDK and added all necessary Enviroment Variables to my System.

ANT 和 JAVA 都可以从任何源路径正常执行.

ANT and JAVA both gets executed fine from any source path.

ant -version 输出

Apache Ant(TM) 1.9.4 版,2014 年 4 月 29 日编译

Apache Ant(TM) version 1.9.4 compiled on April 29 2014

java -version 输出

Java HotSpot(TM) 64 位服务器 VM(构建 25.5-b02,混合模式)

Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)


环境变量

我已经设置了所有必要的变量.从 ANT_HOME 到 PATH.一切都是应该的


Enviroment Variables

I've set up every necessary variable. From ANT_HOME to PATH. Everything is as it should be

ANT_HOME: C:\Program Files\Ant 

JAVA_HOME: C:\Program Files\Java\jdk1.8.0_05

ANDROID_HOME: C:\Users\Kevin\Desktop\Cellulare\Development\sdk

PATH: %JAVA_HOME%\bin;%ANT_HOME%\bin;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools; 

正如大家所见,我还在PATH 中添加了android platform-toolstools.Ant 和 Java (\bin dirs) 也是如此.

As everyone can see, I've also added android platform-tools and tools to my PATH. Same thing for Ant and Java (\bin dirs).

不用说,但每条路径都是正确的.

Needless to say but every path is correct.

说了这么多,为什么还是不行?我也重新启动了我的电脑,但没有结果.

Having this things said, Why this still doesn't work? I've also restarted my PC as well but with no results.

感谢 Kerri Shotts.

我的问题来自路径中的那些空间.

My problems were from those spaces in my paths.

所以我把 C:\Program Files\... 改为 C:\Progra~1\....

重要提示!

我还注意到我的字符串中有 2 个 字符.像这样..\C□□ellulare\...它们可能来自错误的复制粘贴格式.解决这些问题后一切正常!

I also noticed there were 2 characters in my strings. Like this ..\C□□ellulare\... They probably came from a wrong copy-paste format. After fixing these things everything worked!

推荐答案

由于语言的性质,空格在某些情况下会被执行,而在其他情况下会被忽略.从 \bin 目录编译时,使用诸如Program(whitespace)Files"之类的文件名确实会产生错误.下次声明环境变量时,请确保您的文件夹不包含任何空格或各种名称之间的间隙.仅供参考:camelCase 脚本介绍了围绕这个概念的两个工作.谢谢.

Due to the nature of languages, whitespaces are executed in some whilst ignored in others. Utilizing a file name such as "Program(whitespace)Files" does produce errors when compiling from \bin directories. Next time you declare an environmental variable, be sure that your folder does not contain any whitespaces or gaps between the various names. FYI: camelCase scripts where introduced tow work around this concept. Thanks.

这篇关于cordova 添加平台 - 执行命令“ant"时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆