How to build apache cordova project from command line?
Asked Answered
I

4

10
  • I've setup apache cordova on my Windows/Cygwin platform.
  • I can create project using the command - cordova create <app_name>.
  • I have added android platform using the command - cordova platform add android
  • I can run the sample 'html/css/js' using cordova ripple android.
  • I can upload the project to build.phonegap and get the .apk file.
  • I know from docs that I can setup eclipse and do the build. (I'm not looking for this)

  • But I cannot create .apk file using the command cordova build android. When I run the command, there is not output on the command line, the command just finishes. I cannot locate the .apk file.

Is there a way in which I can create an .apk file from command line? (Looking for suggestions for other platforms as well)

Thanks,

Inexpugnable answered 17/6, 2013 at 4:1 Comment(1)
Found this link which seems relevant: wiki.apache.org/cordova/CommandLineToolingDesign. Short answer,in my opinion, the entire HTML5 app stack is still under heavy dev. Expect a bumpy ride.Cacuminal
L
12

You should get a more verbose output by running cordova -d build android.

Alternatively, to use the underlying cordova-android scripts to build, you can:

cd platforms/android
./cordova/build

OR, to peel away even more layers, you can use the Android ANT script to run the build (which is what the cordova scripts shell out to anyways):

cd platforms/android
ant debug
Lamere answered 18/6, 2013 at 16:3 Comment(0)
M
4

For Android the default location for the APKs is the bin directory

The location is defined by ant properties in the Android SDK buil.xml

<import file="${sdk.dir}/tools/ant/build.xml" />

The output apk will be in two formats debug or release

<property name="out.final.file" location="${out.absolute.dir}/${ant.project.name}-debug.apk" />
<property name="out.final.file" location="${out.absolute.dir}/${ant.project.name}-release.apk" />

The location of your apk will be something like this:

  • myAndroidApp/bin/myAndroidApp-debug.apk
  • myAndroidApp/bin/myAndroidApp-release.apk
Matins answered 19/6, 2013 at 12:16 Comment(0)
B
3

Use cordova compile android

This will output a debug .apk file into platforms/android/bin

This works with Cordova 3.3.1

Bleeding answered 9/3, 2014 at 11:40 Comment(1)
IT WORKS But you have to add to local variables a VARIABLE named "ANDROID_HOME" with destination in the Android SDK. I recommend this link =) ccoenraets.github.io/cordova-tutorial/…Manatee
U
0

I was using ant 1.7 which was causing the problem. There was no error message mentioning the version. After changing to Ant 1.8.xx, phonegap was able to install and build the android project.

Uyekawa answered 28/1, 2014 at 3:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.