Technology and Software

Build Mobile Chrome Apps from the command line

Mobile Chrome Apps are great news. I’m finally able to create an Android app using the technologies I know best: HTML, CSS and JavaScript. Not a single line of Java. If you don’t have to use Java you don’t need to use an IDE but how to build it without Eclipse or the like?
Here is how to do it using only command line tools. This is useful in many automation scenarios.

git clone git://
mobile-chrome-apps/mca create eu.connettiva.MyApp
cd MyApp/www
vi config.xml    # write your data
vi manifest.json # write your data
vi background.js # edit it if you're app doesn't
                 # start with index.html

Write your code, then build the Android app.

cd ..
../mobile-chrome-apps/mca build --release
      # or --debug if you don't want to sign the app

The first time you sign you need to generate the keys

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

You must sign the apk and align it every time you build it.

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 \
  -keystore MyApp.keystore \
  platforms/android/bin/MyApp-release-unsigned.apk \
zipalign -f -v 4 \
  platforms/android/bin/MyApp-release-unsigned.apk MyApp.apk

Finally run the app in an emulator. Get the list of available devices with

android avd

and start one of them. Then install the apk in the emulated device with

adb install MyApp.apk # install -r (reinstall)

It’s ready to be used now!

If at any time mca tells you to run mca init to update itself do this:

cd ~/mobile-chrome-apps
./mca init