Cordova Android project from start to finish — quick version of workflow

Here’s a cheat sheet for creating a Cordova app from start to finish. No details on this page; they’re all covered elsewhere on my site. My environment for this is a PC machine with Windows 7 Pro, and this is building an Android project. I’m not using Eclipse or Android Studio — they are not needed.

1. Download Nodejs if you don’t already have it installed. In the Command Prompt:

2. Download and install Android Studio.  Set up the SDK platform for android-22, latest Android SDK Platform-tools, and latest Android SDK Build-tools.

3. Install Cordova if you don’t already have it. In the Command Prompt:

npm install -g cordova

4. Create the default Cordova project files (change myApp to your own app’s name):

cordova create myApp

5. Download the Android platform files:

cordova platform add android

6. Delete the myApp/www folder contents and replace it with your project’s completed HTML, CSS, and JavaScript files.
a. Add all your icons and 9-patch splash screens.
b. Add your plugins. (If this is an update, remove all your core Cordova plugins and replace them with the new versions with this format: cordova plugin add cordova-plugin-device –save. In Config.xml, remove the lines for the plugins you added formerly; –save adds the new information Cordova is using.)
c. Add the Cordova deviceReady API lines to <head> of the pages that use plugins.
d. Update the myApp/config.xml file.
e. Update the permissions in AndroidManifest.xml, if necessary.
f. Validate and check all your work in the browser with Developer tools in a browser.

7. Make an apk to run on your device to test:

cordova build android

The apk file was built and saved as: /myApp/platforms/android/ant-build/helloCordova-debug.apk. (For cordova 5.0.0, it is saved in /myApp/platforms/android/build/outputs/apk.)

Test and adjust project files to suit.

8. When you are ready to upload the project to the app store, run this in the command prompt (change myapp to your app’s name) to make your keystore file:

keytool -genkey -v -keystore myapp.keystore -alias myapp -keyalg RSA -keysize 2048 -validity 10000

Your keystore file will be located at /myApp/myapp.keystore.

9. Copy myapp.keystore to /platforms/android.

10. Now it’s time to sign the app with the key and create the release version. Open /platforms/android/ (or in a text editor.

11. Add these two lines at the end and save (change myapp to your app’s name): 

12. Still in your /myApp folder in Terminal, run:

cordova build android --release

13. Your myApp.apk file is put in /myApp/platforms/android/ant-build/CordovaApp-release.apk. This is the file you rename and upload to Google Play. My build in May 2015, with cordova 5.0.0, had the apk output to /platforms/android/build/outputs/apk.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.