Mostly the app runs as a SPA, though the prototype had an additional requirement to support offline access on devices. To support that I planned to package up the app using PhoneGap.
That's the background... mainly though for this blog post wanted to record some links and notes for getting set up with this framework, and in particular the phonegap build service.
Firstly I looked to use local PhoneGap. To get running found a couple of handy links:
Basic steps are:
- Install JDK
- Install ANT
- Install Android ADK
- Set PATH variables for java, ant and android
I went a bit further with that but had lots of problems with the emulator. Very slow and often failed to load. Maybe I need a new laptop but instead decided to turn to PhoneGap build and deploy direct to my device (a Samsung mobile running Android).
Getting started with this is very straightforward. Sign up using a Github account. In terms of code the only change I initially made was to add a script reference to phonegap.js - you don't need the file though, the service places the appropriate one in when compiling for each platform - and then upload a zip file of the SPA files.
Once build complete you can download the .apk for Android. Some other platforms weren't completing due to missing keys and config file - but can get to that later as the Android one was OK.
On the mobile device itself had to make a couple of setting changes under Applications:
- enabling "unknown sources"
- enabling USB debugging
Having already installed and setup the Android SDK could then use the command line to install to the device once connected via the USB port.
Firstly to check the device is found:
Then to install:
adb install -r [path to apk file]
The -r flag ensures the app is overwritten even if it is already installed
adb logcat -s "CordovaLog"
In order to test in a browser the Ripple Emulator Chrome plugin is a useful tool. It implements a number of the PhoneGap APIs so you can test without installing on the device.