Reputation: 2309
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
Upvotes: 9
Views: 33711
Reputation: 31
When you get the error
Command failed with exit code 2
The cause can be because of your android SDK not fully or correctly installed. To solve this you can try to edit the file \platforms\android\project.properties
and change
target=android-22
To something like
target=android-21
Or another target in which you have successfully built app in the past. This will download a new gradle and that's all you need to build your project.
Upvotes: 3
Reputation: 3256
That happens when you change the version
tag from "0.0.1" to "0.1" on the config.xml
file.
But according to the PhoneGap doc, it must be major/minor/patch :
The element's id attribute provides the app's reverse-domain identifier, and the version its full version number expressed in major/minor/patch notation.
http://docs.phonegap.com/en/3.5.0/config_ref_index.md.html
Upvotes: 2
Reputation: 199
Remove your platform and add it again .It solved my problem
Remove android platform:
ionic platform rm android
Add it again:
ionic platform add android
make sure that you take backup of res folder. if you have any icons or splash screens..
Upvotes: 2
Reputation: 2910
My story was that I somehow managed to have two node_modules
folders, one in the root of my Phonegap project and another one inside the www
of the AngularJS app I was trying to "port" using Phonegap. I received a stacktrace such as
..
unable to process assets while packaging
<..>\node_modules\semver\semver.browser.js.gz': file already in archive (try '-u'?)
..
<..>\android-sdk\tools\ant\build.xml:950: null returned: 1
Also received a \cordova\build.bat: Command failed with exit code 8
but I don't know if the two errors are related.
Deleting the node_modules
folder from the www
folder did the trick. Running Win7 x64.
Upvotes: 1
Reputation: 11642
I solved it by delete of content these folders:
/platforms/android/ant-build
/platforms/android/ant-gen
/platforms/android/bin
/platforms/android/gen
Upvotes: 5
Reputation: 101
Renaming the android folder and again running the 'phonegap local build android' worked for me when I had the same error.
Upvotes: 6
Reputation: 11721
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)
Upvotes: 3