PhoneGap - 生成错误 [英] PhoneGap - Build error
问题描述
我是phonegap的新手,尝试通过输入如phonegap 安装网页上所述的命令创建一个简单的测试应用程序
不幸的是,我在命令行中遇到以下错误:
BUILD FAILED
E:\ProgramFiles(x86)\AndroidSDK\tools\ant\build.xml:892:执行此行时出现以下错误:
urred:
E:\ProgramFiles(x86)\AndroidSDK\tools\ant\build.xml:894:执行此行时出现以下错误:
E:\ProgramFiles x86)\AndroidSDK\tools\ant\build.xml:906:执行此行时出现以下错误:
E:\ProgramFiles(x86)\AndroidSDK\ tools \ant\build.xml:284:null返回:1
总时间:4秒
命令的错误代码1:cmd with args:/ s,/ c,ant ,debug,-f,E:\Projects\Mobile\P
honeGap\test-app\platforms\android\build.xml,-Dout.dir = ant-build,-Dgen 。绝对。
dir = ant-gen
[error] cmd:命令失败,退出代码2
我使用Windows 7 64位。我的环境变量如下所示:
ANDROID_HOME = E:\ProgramFiles(x86)\AndroidSDK
ANT_HOME = E:\Projects\Mobile\Eclipse\plugins\org.apache.ant_1.8.3.v201301120609
JAVA_HOME = C:\Program Files\Java\jdk1.7.0_51
然而,如果我在命令行中键入ant,我会得到以下消息:
E:\Projects\Mobile\PhoneGap\test-app> ant
Buildfile:build.xml不存在!
生成失败
这可能是原因吗?
感谢任何帮助!
编辑:
这是命令行中的完整输出:
E:\Projects\Mobile \PhoneGap \test-app> phonegap run android
[phonegap]检测Android SDK环境...
[phonegap]使用本地环境
[phonegap]编译Android ...
[ReferenceError:a未定义]
Buildfile:E:\Projects\Mobile\PhoneGap\test-app\platforms\android\build.xml
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK工具修订版22.3。 0
[checkenv]安装在E:\ProgramFiles(x86)\AndroidSDK
-setup:
[echo]项目名称:HelloWorld
[gettype]项目类型:应用程序
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools]使用最新的Build Tools:19.0.0
[echo]解决HelloWorld的构建目标...
[gettarget]项目目标: Android 4.4
[gettarget] API级别:19
[echo] ----------
[echo]如果需要,创建输出目录...
[ mkdir]创建目录:E:\Projects\Mobile\PhoneGap\test-app\platforms\android\
ant-build\rsObj
[mkdir]创建目录:E :\Projects\Mobile\PhoneGap\test-app\platforms\android\
ant-build\rsLibs
[echo] ----------
[echo]解析HelloWorld的依赖关系
[dependency]库依赖关系:
[dependency]
[dependency] ------------ ------
[dependency]有序库:
[dependency]
[dependency] ------------------
[echo] ----------
[echo]用'debug'构建库
nodeps:
- set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK工具修订版22.3.0
[checkenv]安装在E:\ProgramFiles(x86)\AndroidSDK
-setup:
[echo]项目名称:CordovaLib
[gettype] Android库
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools]使用最新的Build Tools:19.0.0
[echo]解决CordovaLib的构建目标...
[gettarget]项目目标:Android 4.4
[gettarget] API级别:19
[echo] ----------
[echo]如果需要,创建输出目录...
[mkdir]创建dir:E:\Projects\Mobile\PhoneGap\test-app\platforms\android\
CordovaLib \ant-build \rsObj
[mkdir]创建目录: E:\Projects\Mobile\PhoneGap\test-app\platforms\android\
CordovaLib\ant-build\rsLibs
[echo] ------ ----
[echo]解析CordovaLib的依赖关系...
[dependency]库依赖关系:
[dependency]否库
[dependency]
[dependency ] ------------------
-code-gen:
[mergemanifest]发现已删除的目标文件
[mergemanifest]将AndroidManifest文件合并为一个。
[mergemanifest]清单合并禁用。仅使用项目清单。
[echo]处理aidl文件...
[aidl]没有要编译的AIDL文件。
[echo] ----------
[echo]处理RenderScript文件...
[echo] ----------
[echo]处理资源...
[aapt]找到新的输入文件
[aapt]生成资源ID ...
[echo] ----------
[echo]处理BuildConfig类...
[buildconfig]无需生成新的BuildConfig。
-pre-compile:
-compile:
[echo]创建库输出jar文件...
-post-编译:
-obfuscate:
-dex:
[echo]库项目:不转换字节码...
- crunch:
[crunch]源代码中的PNG文件dir:E:\Projects\Mobile\PhoneGap\test-
app\platforms\android\CordovaLib\res
[crunch]到目的地目录:E:\Projects\Mobile\PhoneGap\test-app\platforms\a
ndroid\CordovaLib\ant-build\res
[crunch] crunched 0 PNG文件以更新缓存
-package-resources:
[echo]库项目:不打包资源...
- package:
[echo]库项目:do not package apk ...
-post-package:
-do-debug:
[ echo]库项目:不创建apk ...
[propertyfile]更新属性文件:E:\Projects\Mobile\PhoneGap\test-app\plat
forms\android \CordovaLib\ant-build\build.prop
[propertyfile]更新属性文件:E:\Projects\Mobile\PhoneGap\test-app\plat
forms\ android\CordovaLib\ant-build\build.prop
[propertyfile]更新属性文件:E:\Projects\Mobile\PhoneGap\test-app\plat
forms\\ \\android\CordovaLib\ant-build\build.prop
[propertyfile]更新属性文件:E:\Projects\Mobile\PhoneGap\test-app\plat
形式\android \CordovaLib\ant-build\build.prop
-post-build:
debug:
-code- gen:
[mergemanifest]发现已删除的目标文件
[mergemanifest]将AndroidManifest文件合并为一个文件。
[mergemanifest]清单合并禁用。仅使用项目清单。
[echo]处理aidl文件...
[aidl]没有要编译的AIDL文件。
[echo] ----------
[echo]处理RenderScript文件...
[echo] ----------
[echo]处理资源...
[aapt]找到已删除的目标文件
[aapt]生成资源ID ...
[echo] ----------
[echo]处理BuildConfig类...
[buildconfig]生成BuildConfig类。
-pre-compile:
[echo]将jars路径设置为:E:\Projects\Mobile\PhoneGap\test-app\platforms\and
roid \CordovaLib\ant-build\classes.jar
-compile:
[javac]将2个源文件编译为E:\Projects\Mobile\PhoneGap\\ \\test-app\pla
tforms\android\ant-build\classes
-post-compile:
-obfuscate:
-dex:
[dex]输入:E:\Projects\Mobile\PhoneGap\test-app\platforms\android\ant-bu
ild\\ \\ classes
[dex]输入:E:\Projects\Mobile\PhoneGap\test-app\platforms\android\Cordov
aLib \ant-build \classes。 jar
[dex] Pre-Dexing E:\Projects\Mobile\PhoneGap\test-app\platforms\android\Co
rdovaLib\ant-build\classes。 jar - > classes-e1aa4bb1e6a0a2f38f9e3036d5cbe6f6.jar
[dx]'E:\ProgramFiles'不能识别为内部或外部逗号
nd,
[dx]可操作的程序或批处理文件。
BUILD FAILED
E:\ProgramFiles(x86)\AndroidSDK\tools\ant\build.xml:892:执行时出现以下错误
urred这行:
E:\ProgramFiles(x86)\AndroidSDK\tools\ant\build.xml:894:执行此行时出现以下错误:
urred:
E:\ProgramFiles(x86)\AndroidSDK\tools\ant\build.xml:906:执行此行时出现以下错误:
E:\ProgramFiles(x86 )\AndroidSDK\tools\ant\build.xml:284:null返回:1
总时间:2秒
命令错误代码1:cmd with args:/ s,/ c,ant,debug,-f,E:\Projects\Mobile\P
honeGap \test-app\platforms\android\build.xml,-Dout.dir = ant-build,-Dgen.absolute。
dir = ant-gen
[error] cmd:命令失败,退出代码2
解决方案在错误日志中,您将看到消息
\\ ProgramFiles'不被识别为内部或外部命令,可操作的程序或批处理文件。
您配置了 ANDROID_HOME = E:\ProgramFiles(x86)\AndroidSDK
这看起来很奇怪,因为通常文件夹名为 C:\Program Files(x86)
(有空格)。
您的AndroidSDK是否真的安装在名为E:\ProgramFiles(x86)的文件夹中?
我真的不认为这是问题,因为SDK似乎找到了,但我不得不问的反正...
更多likelly,我认为在cordova构建脚本的某个地方可能有一条不喜欢路径中的圆括号()的线。
要ckeck这个而不会弄乱你的conf ,您可以在cmd中尝试此操作(更改将在关闭cmd后丢失):
subst z:E:\ ProgramFiles(x86)\AndroidSDK
set ANDROID_HOME = z:\
phonegap build android
$ b b
(如果您已使用Z驱动器,请将Z替换为其他文件夹)
I'm very new to phonegap and tried to create a simple test app by entering the commands like described on the phonegap install webpage
Unfortunately, I get the following error in the command-line:
BUILD FAILED
E:\ProgramFiles(x86)\AndroidSDK\tools\ant\build.xml:892: The following error occ
urred while executing this line:
E:\ProgramFiles(x86)\AndroidSDK\tools\ant\build.xml:894: The following error occ
urred while executing this line:
E:\ProgramFiles(x86)\AndroidSDK\tools\ant\build.xml:906: The following error occ
urred while executing this line:
E:\ProgramFiles(x86)\AndroidSDK\tools\ant\build.xml:284: null returned: 1
Total time: 4 seconds
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,E:\Projects\Mobile\P
honeGap\test-app\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.
dir=ant-gen
[error] cmd: Command failed with exit code 2
I use Windows 7 64-bit. My environment variables look like the following:
ANDROID_HOME = E:\ProgramFiles(x86)\AndroidSDK
ANT_HOME = E:\Projects\Mobile\Eclipse\plugins\org.apache.ant_1.8.3.v201301120609
JAVA_HOME = C:\Program Files\Java\jdk1.7.0_51
Nevertheless, if I type in "ant" in the command shell, I get the following message:
E:\Projects\Mobile\PhoneGap\test-app>ant
Buildfile: build.xml does not exist!
Build failed
Could that probably be the reason?
Thanks for any help!
EDIT:
Here is the complete output in the commandline:
E:\Projects\Mobile\PhoneGap\test-app>phonegap run android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] compiling Android...
[ReferenceError: a is not defined]
Buildfile: E:\Projects\Mobile\PhoneGap\test-app\platforms\android\build.xml
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 22.3.0
[checkenv] Installed at E:\ProgramFiles(x86)\AndroidSDK
-setup:
[echo] Project Name: HelloWorld
[gettype] Project Type: Application
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools] Using latest Build Tools: 19.0.0
[echo] Resolving Build Target for HelloWorld...
[gettarget] Project Target: Android 4.4
[gettarget] API level: 19
[echo] ----------
[echo] Creating output directories if needed...
[mkdir] Created dir: E:\Projects\Mobile\PhoneGap\test-app\platforms\android\
ant-build\rsObj
[mkdir] Created dir: E:\Projects\Mobile\PhoneGap\test-app\platforms\android\
ant-build\rsLibs
[echo] ----------
[echo] Resolving Dependencies for HelloWorld...
[dependency] Library dependencies:
[dependency]
[dependency] ------------------
[dependency] Ordered libraries:
[dependency]
[dependency] ------------------
[echo] ----------
[echo] Building Libraries with 'debug'...
nodeps:
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 22.3.0
[checkenv] Installed at E:\ProgramFiles(x86)\AndroidSDK
-setup:
[echo] Project Name: CordovaLib
[gettype] Project Type: Android Library
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools] Using latest Build Tools: 19.0.0
[echo] Resolving Build Target for CordovaLib...
[gettarget] Project Target: Android 4.4
[gettarget] API level: 19
[echo] ----------
[echo] Creating output directories if needed...
[mkdir] Created dir: E:\Projects\Mobile\PhoneGap\test-app\platforms\android\
CordovaLib\ant-build\rsObj
[mkdir] Created dir: E:\Projects\Mobile\PhoneGap\test-app\platforms\android\
CordovaLib\ant-build\rsLibs
[echo] ----------
[echo] Resolving Dependencies for CordovaLib...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
-code-gen:
[mergemanifest] Found Deleted Target File
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] Found new input file
[aapt] Generating resource IDs...
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] No need to generate new BuildConfig.
-pre-compile:
-compile:
[echo] Creating library output jar file...
-post-compile:
-obfuscate:
-dex:
[echo] Library project: do not convert bytecode...
-crunch:
[crunch] Crunching PNG Files in source dir: E:\Projects\Mobile\PhoneGap\test-
app\platforms\android\CordovaLib\res
[crunch] To destination dir: E:\Projects\Mobile\PhoneGap\test-app\platforms\a
ndroid\CordovaLib\ant-build\res
[crunch] Crunched 0 PNG files to update cache
-package-resources:
[echo] Library project: do not package resources...
-package:
[echo] Library project: do not package apk...
-post-package:
-do-debug:
[echo] Library project: do not create apk...
[propertyfile] Updating property file: E:\Projects\Mobile\PhoneGap\test-app\plat
forms\android\CordovaLib\ant-build\build.prop
[propertyfile] Updating property file: E:\Projects\Mobile\PhoneGap\test-app\plat
forms\android\CordovaLib\ant-build\build.prop
[propertyfile] Updating property file: E:\Projects\Mobile\PhoneGap\test-app\plat
forms\android\CordovaLib\ant-build\build.prop
[propertyfile] Updating property file: E:\Projects\Mobile\PhoneGap\test-app\plat
forms\android\CordovaLib\ant-build\build.prop
-post-build:
debug:
-code-gen:
[mergemanifest] Found Deleted Target File
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] Found Deleted Target File
[aapt] Generating resource IDs...
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.
-pre-compile:
[echo] Set jars path to: E:\Projects\Mobile\PhoneGap\test-app\platforms\and
roid\CordovaLib\ant-build\classes.jar
-compile:
[javac] Compiling 2 source files to E:\Projects\Mobile\PhoneGap\test-app\pla
tforms\android\ant-build\classes
-post-compile:
-obfuscate:
-dex:
[dex] input: E:\Projects\Mobile\PhoneGap\test-app\platforms\android\ant-bu
ild\classes
[dex] input: E:\Projects\Mobile\PhoneGap\test-app\platforms\android\Cordov
aLib\ant-build\classes.jar
[dex] Pre-Dexing E:\Projects\Mobile\PhoneGap\test-app\platforms\android\Co
rdovaLib\ant-build\classes.jar -> classes-e1aa4bb1e6a0a2f38f9e3036d5cbe6f6.jar
[dx] 'E:\ProgramFiles' is not recognized as an internal or external comma
nd,
[dx] operable program or batch file.
BUILD FAILED
E:\ProgramFiles(x86)\AndroidSDK\tools\ant\build.xml:892: The following error occ
urred while executing this line:
E:\ProgramFiles(x86)\AndroidSDK\tools\ant\build.xml:894: The following error occ
urred while executing this line:
E:\ProgramFiles(x86)\AndroidSDK\tools\ant\build.xml:906: The following error occ
urred while executing this line:
E:\ProgramFiles(x86)\AndroidSDK\tools\ant\build.xml:284: null returned: 1
Total time: 2 seconds
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,E:\Projects\Mobile\P
honeGap\test-app\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.
dir=ant-gen
[error] cmd: Command failed with exit code 2
解决方案 In the error log you'll see the message
E:\ProgramFiles' is not recognized as an internal or external command, operable program or batch file.
You configured ANDROID_HOME = E:\ProgramFiles(x86)\AndroidSDK
which seems weird for me because normally the folder is named C:\Program Files (x86)
(with a space).
Is your AndroidSDK really installed in the folder named E:\ProgramFiles(x86)?
I don't really think it's the issue, since the SDK seems to be found, but I had to ask anyway...
More likelly, I think that somewhere in the cordova build scripts there may be a line that doesn't like the round brackets () in the path.
To ckeck this without messing with your conf, you can try this in a cmd (changes will be lost after closing the cmd):
subst z: E:\ProgramFiles(x86)\AndroidSDK
set ANDROID_HOME=z:\
phonegap build android
(replace Z with an other lerrer if you're already using the Z drive)
这篇关于PhoneGap - 生成错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!