I've just downloaded Cordova, along with all the requirements for Android and Windows Phone. I can successfully build a WP8 image and send it to my 8X, however, I can't seem to be able to build an Android image.
When I execute cordova build android, I get the following error:
Generating config.xml from defaults for platform "android"
Preparing android project
Compiling app on platform "android" via command "cmd" /c Y:\mobile\platforms\android\cordova\build
C:\Users\x\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:126
throw e;
^
Error: An error occurred while building the android project.
at ChildProcess.<anonymous> (C:\Users\x\AppData\Roaming\npm\node_modules\cordova\src\compile.js:65:22)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
And when I launch the build command manually, I get the following error:
Error executing "ant debug -f "Y:\mobile\platforms\android\build.xml"":
BUILD FAILED
C:\Development\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:962: The following error occurred while executing this line:
C:\Development\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:973: The following error occurred while executing this line:
C:\Development\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:313: com.android.sdklib.build.ApkCreationException: Y:\mobile\platforms\android\bin\rs
Libs does not exist
at com.android.sdklib.build.ApkBuilder.getNativeFiles(ApkBuilder.java:742)
at com.android.ant.ApkBuilderTask.execute(ApkBuilderTask.java:303)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
It seems that the cordova-3.3.0.jar file doesn't get compiled, shouldn't it get compiled automatically? Is there anything I'm missing?
It can be an error with Ant. I had this error because I forgot to change the environment variable path.
The path I added was wrong (you need to specify this folder: "way\to\apache-ant-1.9.3\bin"). I just changed it and it works now.
(If it's not that, it can be an other path environment variable such as node, or your java sdk or android sdk)
Hope it can help someone.
I just deleted the whole Android project, recompiled the CordovaLibs and recompiled the Android project. Seems to have fixed it.
try commands
cordova platform rm android
cordova platform add android
cordova build android
Related
Here is a PATH in environment :
C:\Users\user\AppData\Roaming\npm;D:\work\SDK\SoftPhonegap\ADT\sdk\platform-tools;D:\work\SDK\SoftPhonegap\ADT\sdk\tools;D:\work\SDK\SoftPhonegap\apache-ant-1.9.5\bin;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Java\jdk1.7.0_51\bin;C:\Program Files\Java\jdk1.8.0_45\bin;D:\work\SDK\SoftPhonegap\ADT\sdk\build-tools
A. Error log of cordova build android
BUILD FAILED
D:\work\SDK\SoftPhonegap\ADT\sdk\tools\ant\build.xml:601: The following error oc
curred while executing this line:
D:\work\SDK\SoftPhonegap\ADT\sdk\tools\ant\build.xml:542: Unable to resolve proj
ect target 'android-21'
Total time: 0 seconds
D:\work\SDK\SoftPhonegap\ADT\hello\platforms\android\cordova\node_modules\q\q.js
:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "ant debug -f D:\work\SDK\SoftPho
negap\ADT\hello\platforms\android\build.xml -Dout.dir=ant-build -Dgen.absolute.d
ir=ant-gen"
ERROR building one of the platforms: Error: D:\work\SDK\SoftPhonegap\ADT\hello\p
latforms\android\cordova\build.bat: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: D:\work\SDK\SoftPhonegap\ADT\hello\platforms\android\cordova\build.bat: C
ommand failed with exit code 8
at ChildProcess.whenDone (C:\Users\user\AppData\Roaming\npm\node_modules\cor
dova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
B Error log of Ant
C:\Users\user>ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.8.
0_45\lib\tools.jar
Buildfile: build.xml does not exist!
Build failed
C. when add platform android
D:\work\SDK\SoftPhonegap\ADT\hello>cordova platform add android
npm http GET https://registry.npmjs.org/cordova-android/3.7.2
npm http 304 https://registry.npmjs.org/cordova-android/3.7.2
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms\android
Package: com.example.hello
Name: HelloWorld
Android target: android-21
Copying template files...
Project successfully created.
Installing "com.phonegap.plugins.PushPlugin" for android
Installing "com.salesforce" for android
Installing "org.apache.cordova.device" for android
Could not run SalesforceMobileSDK plugin android pre-install script
You are running node v0.10.25
You need to be running node 0.12 or above
You won't be able to successfully run: cordova build
Running SalesforceMobileSDK plugin android post-install script
The "android" utility does not exist at D:\work\SDK\SoftPhonegap\ADT\sdk\tools;D
:\work\SDK\SoftPhonegap\ADT\sdk\platform-tools\tools\android.bat. Make sure you
've properly installed the Android SDK.
I think you need to give platform_tools pah also, you should post your error log,
anyway here is how my PATH looks like
C:\Users\amitabhs\AppData\Roaming\npm;F:\Softs\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\platform-tools;F:\Softs\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\tools;F:\Softs\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\platforms;C:\Program Files\Java\jdk1.8.0_45\bin;C:\Program Files\apache-ant-1.9.5\bin;
check if it helps
Compile your project in https://build.phonegap.com/
There you have no problems with OS and can compile for all OS.
I use then for IOS compilation.
Solution:
Uninstall node v0.10.25
install node 0.12 or above
remove platform android (cordova platform rm android)
add platform android (cordova platform add android)
build android (cordova build android)
Done
I'm setting up an environment for Phonegap developing, and I'm getting some trouble to finally build and run an app for Android.
When I try to execute build for Android, I got the following error:
Running: C:\Users\Renan\workspace_html5\FIAP\Phonegap\phonegap-test\test\platfor
ms\android\gradlew cdvBuildDebug -b C:\Users\Renan\workspace_html5\FIAP\Phonegap
\phonegap-test\test\platforms\android\build.gradle -Dorg.gradle.daemon=true
Unzipping C:\Users\Renan\.gradle\wrapper\dists\gradle-2.2.1-all\2m8005s69iu8v0oi
ejfej094b\gradle-2.2.1-all.zip to C:\Users\Renan\.gradle\wrapper\dists\gradle-2.
2.1-all\2m8005s69iu8v0oiejfej094b
Exception in thread "main"
java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip fil
e
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:78)
at org.gradle.wrapper.Install.createDist(Install.java:47)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:220)
at java.util.zip.ZipFile.<init>(ZipFile.java:150)
at java.util.zip.ZipFile.<init>(ZipFile.java:164)
at org.gradle.wrapper.Install.unzip(Install.java:160)
at org.gradle.wrapper.Install.access$400(Install.java:29)
at org.gradle.wrapper.Install$1.call(Install.java:70)
at org.gradle.wrapper.Install$1.call(Install.java:47)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:65)
... 3 more
C:\Users\Renan\workspace_html5\FIAP\Phonegap\phonegap-test\test\platforms\androi
d\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "C:\Users\Renan\workspace_html5\F
IAP\Phonegap\phonegap-test\test\platforms\android\gradlew cdvBuildDebug -b C:\Us
ers\Renan\workspace_html5\FIAP\Phonegap\phonegap-test\test\platforms\android\bui
ld.gradle -Dorg.gradle.daemon=true"
ERROR building one of the platforms: Error: C:\Users\Renan\workspace_html5\FIAP\
Phonegap\phonegap-test\test\platforms\android\cordova\build.bat: Command failed
with exit code 8
You may not have the required environment or OS to build this project
Error: C:\Users\Renan\workspace_html5\FIAP\Phonegap\phonegap-test\test\platforms
\android\cordova\build.bat: Command failed with exit code 8
at ChildProcess.whenDone (C:\Users\Renan\AppData\Roaming\npm\node_modules\ph
onegap\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:1
31:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
Some details:
I'm running on Windows 8.1;
I'm using Android SDK 22;
I've already created environment variables for JDK, Android (tools, build-tools and platform-tools), Ant and Gradle.
Any ideas why am I getting this error?
Thank you.
I have already managed to solve this problem, so, in case of anyone has a similar trouble, here it goes the situation I've gone through.
When I performed the first build, phonegap attempted to download and extract it's own gradle distribution, and he was attempting to download it from the follow:
http://services.gradle.org/distributions/gradle-2.2.1-all.zip
By the time, I was connected on university's network, and this URL was blocked by it's proxy. Since I wasn't able to reach the URL above, all Phonegap could do was to get a corrupted zip file, so that was the reason that exception has been throwed.
Even when I deleted ~/.gradle, I was trying to build on the same network.
So, in order to solve this problem, I have just deleted .gradle directory and run the build using another network connection.
I have created a Cordova Application Project using the CLI tool and NetBeans IDE for Cordova Project. I have also mapped the following path variables.
ANDROID_HOME F:\AndroidProjects\adt-bundle-windows-x86-20131030\
ANT_HOME C:\apache-ant-1.9.4\
JAVA_HOME C:\Program Files\Java\jdk1.8.0_25\
PATH C:\Users\Administrator\AppData\Roaming\npm;F:\Android Projects\adt-bundle-windows-x86-20131030\sdk\platform-tools\;F:\AndroidProjects\adt-bundle-windows-x86-20131030\SDK\TOOLS\;C:\Program Files\Java\jdk1.8.0_25\bin;%JAVA_HOME%\bin;C:\Program Files (x86)\Git\;C:\Program Files (x86)\Git\bin;%ANT_HOME%/bin;
I am also able to run the Demo Cordova Application on AVD and Real device,using eclipse. But, while trying to build the project with additional changes the CLI is giving me with the following error message
[Error: ANDROID_HOME is set to a non-existant path: F:\Android
Projects\adt-bund le-windows-x86-20131030] Command finished with error
code 2: F:\CordovaProjects\CordovaAppOne\platforms\a
ndroid\cordova\build.bat Error:
F:\CordovaProjects\CordovaAppOne\platforms\android\cordova\build.bat:
Com mand failed with exit code 2
at ChildProcess.whenDone (C:\Users\Administrator\AppData\Roaming\npm\node_mo
dules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
What should I set in addition to the above to resolve the error. I am using Windows8-64Bit on administrator account. Only Android platform has been added to the application using the CLI.
Issue has been resolved. The issue was raised due to wrong pointing of ANDROID_HOME environment variable. It is required that the variable directly points to sdk folder itself instead of the Android Eclipse bundle.
I was having an error that is Camera not successful invoked on first try (click) so I tried this solution on stackoverflow Phonegap(3.0.0) Camera not successful on first try.
I followed the steps as mentioned in the answer removed android by cordova platform remove android then I run the second command cordova platform add android ;
Now when I use netbeans to run the cordova application on cordova android decvice this error occurs:
exec: ant debug -f "/var/www/mobile/platforms/android/build.xml"
[ 'ant debug -f "/var/www/mobile/platforms/android/build.xml"',
{ [Error: Command failed:
BUILD FAILED
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
Total time: 8 seconds
] killed: false, code: 1, signal: null },
'Buildfile: /var/www/mobile/platforms/android/build.xml\n\n-set-mode-check:\n\n-set-debug-files:\n\n-check-env:\n [checkenv] Android SDK Tools Revision 22.3.0\n [checkenv]
.
.
.**LONG TEXT which I removed from the post **
.
\nBUILD FAILED\n/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720:
The following error occurred while executing this line:\n/var/www/adt-bundle-linux-x86_64- 20130917/sdk/tools/ant/build.xml:734:
Compile failed; see the compiler error output for details.\n\nTotal time: 8 seconds\n' ]
Error executing "ant debug -f "/var/www/mobile/platforms/android/build.xml"":
BUILD FAILED
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
Total time: 8 seconds
child_process.spawn(/var/www/mobile/platforms/android/cordova/build,[]) = 2
/usr/local/lib/node_modules/cordova/node_modules/q/q.js:126
throw e;
Error: An error occurred while building the android project.Error executing "ant debug -f "/var/www/mobile/platforms/android/build.xml"":
BUILD FAILED
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/var/www/adt-bundle-linux-x86_64-20130917/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
Total time: 8 seconds
at ChildProcess.<anonymous> (/usr/local/lib/node_modules/cordova/src/compile.js:65:22)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
/var/www/mobile/nbproject/build.xml:256: exec returned: 8
BUILD FAILED (total time: 4 minutes 36 seconds)
any idea about this problem?
I was having a similar issue. I ran ant debug -f "/path/to/project/build.xml" from a separate terminal. It displayed a more specific description of the error (which for me wast that there was a space in the project name). This answer also notes:
config.xml can't have a widget id with number as a first character
after a dot. For example: com.42myapp.test or com.myapp.42test won't
work as well as 42com.myapp.test. It will trigger an error from the
compiler.
I was facing similar issues when i started using the CLI to build apps using cordova and started checking the internet for solutions. While i was at it, i discovered the following things that may help you or anyone else facing the same problem can take some hints from this:
These are some very basic checks that you need to take
1. make sure you have all the required sdk's in place (ANT, Java, Android) and is available when you use these commands on the terminal/command $ ant $ java $ adt. if any of these commands are not found, then you need to get it installed or get the class paths fixed.
make sure your project path does not have spaces. i.e. do not have spaces or special characters in directory names. this issue seems to have been fixed on latest versions of cordova and phonegap, but either cases it is a good practice to follow as ant and java paths could be dependent on the folder names you make.
use -d or -v to get extra debug information on the build process to know where and what is causing the issue. $ cordova build android -d or $ cordova build android -v
Make sure you dont use "#" as the link attribute of author tag in the cordova config.xml on the root of the project. This expects the compiler to interpret a hexadecimal color and fails the build. (this was my problem)
Hope this helps.
er... Happy debugging??
Make sure your Ant is 1.8.0 or later version. Cordova 3.3 demands that.
In the past several days, I found that the conflicting files from Dropbox had a very long name. After renaming it, everything worked.
I'm trying to build simple android project from Jenkins, but build fails with output message (verbose):
Building in workspace /var/lib/jenkins/jobs/MyProj/workspace
[MyProj] $ ant -file build.xml help -v
Apache Ant version 1.8.1 compiled on October 13 2010
Buildfile: /home/ramps/MyProj/build.xml
Detected Java version: 1.6 in: /usr/lib/jvm/java-6-openjdk/jre
Detected OS: Linux
parsing buildfile /home/ramps/MyProj/build.xml with URI = file:/home/ramps/MyProj/build.xml
Project base dir set to: /home/ramps/MyProj
parsing buildfile jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
[property] Loading /home/ramps/MyProj/local.properties
[property] Loading /home/ramps/MyProj/ant.properties
Importing file /home/ramps/MyProj/custom_rules.xml from /home/ramps/MyProj/build.xml
Cannot find /home/ramps/MyProj/custom_rules.xml imported from /home/ramps/MyProj/build.xml
Importing file /usr/share/android-sdk-linux/tools/ant/build.xml from /home/ramps/MyProj/build.xml
BUILD FAILED
/home/ramps/MyProj/build.xml:81: Cannot find /usr/share/android-sdk-linux/tools/ant/build.xml imported from /home/ramps/MyProj/build.xml
at org.apache.tools.ant.taskdefs.ImportTask.importResource(ImportTask.java:181)
at org.apache.tools.ant.taskdefs.ImportTask.execute(ImportTask.java:162)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:179)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:82)
at org.apache.tools.ant.Main.runBuild(Main.java:786)
at org.apache.tools.ant.Main.startAnt(Main.java:218)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
MyProj is a clean project created via:
android create project --name MyProj --package com.myproj --target "android-15" --path MyProj --activity MyProj
of course file "/usr/share/android-sdk-linux/tools/ant/build.xml" exist.
"ant help" from shell runs fine.
local.properties contains valid path to android SDK:
sdk.dir=/usr/share/android-sdk-linux
Any idea why MyProj/build.xml cannot find "/usr/share/android-sdk-linux/tools/ant/build.xml" ?
Ok, I managed to solve it. User jenkins had no permission to enter android-sdk-linux folder.
In general, when debugging such issues it is very helpful to try to do manually what Jenkins is doing:
$sudo su jenkins
And now, as jenkins user try to enter folders, create new one etc.