Running Your Android/Cordova App

Running the app

If this is your first Android/Cordova app, you’re going to find out pretty quickly (like in the first 5 minutes) that you’ll need a place to run it. You have a few options:

On Your Phone

It is easy to run the app on your own Android phone.  I’m listing this option first because it is reasonably quick, and quicker than the SDK emulator.   First go to Settings, turn on Developer Options and make sure USB Debugging is checked.    You can then connect to your development machine with a USB and execute:

cordova run android

Android SDK Emulators/Virtual Devices

The Android SDK comes with a variety of emulators, none of which are initially installed.  First run the Android Virtual Devices manager:

android avd

Here you can create one or more Virtual Devices which emulate different phones.  Add a new device and configure it.   Virtual devices can also be downloaded from smart phone manufacturers, if you want to be specific in your testing.  The following command will build and run your app on the virtual device:

cordova emulate android

Of course you can specify which virtual device you want to start up, or use the default.

This emulator is probably the most accurate representation of a phone that you can run, without actually installing on a real one.   But it is very slow to start up and run.  I found myself looking for an alternative almost immediately.

Just Use the Browser

It quickly occurred to me that because I was writing an HTML/JavaScript app (Cordova) that I could just run it in the browser.  So I chose my favorite node.js based lightweight server and was up and running in a few minutes.  This worked fine for basic functionality, and of course is very handy for addressing JavaScript issues.  This is the world I expect to work in, for most of my app’s functionality, because I’m using Ionic/AngularJS.

However this approach has a few disadvantages:  it’s not going to win any awards for appearance – I could not use this method for a client demo or screen shots.   And worst of all, it is ONLY for web functionality.

Also, I ran into an issue which didn’t show up here.  Of course.  It’s not running any of the Cordova scaffolding, so the minute you start changing configuration settings or want to check permissions, you need something more “real”.   I expect this method to break if I write custom extensions or need other features that chrome does not offer.

Ripple

I have used Ripple on a limited basis, but it appears to be a nice compromise between the incredibly slow SDK emulator and the “just run in browser” approach.

If you’re new to Ripple, here’s the 30 second low-down: It runs within Chrome, but you start it from the command line.   Do NOT install the chrome extension.  Just install it from npm as follows:

npm install -g ripple-emulator

You’ll still need to run in your phone or the SDK emulator, and I suggest doing so whenever you make a change to the configuration or underlying Java.  For example, the renaming problem I encountered did not show up in Ripple, though it did in the SDK emulator.

In summary, I expect you’ll be looking at your app using a variety of methods, depending on what you’re testing or need to do.    Let me know if I’ve left anything out, and good luck!

2 comments

Leave a Reply

Your email address will not be published. Required fields are marked *