Yet another personnal blog

Various notes about some adventures in the digital era, and more.

Thirst of skills : Cordova


Cordova

Cordova is a Javascript framework designed to develop mobile apps. It targets the main mobile devices (Android, iOS) and still targets legacy ones (Firefox OS, Blackberry, Windows Phone). As of writing, the actual version is 7.x.

Cordova requires NodeJS.

The quick tour is here and allow the creation of some Hello World app that you can push to your physical device or that you can push to some Android virtual device, thanks to kvm (Kernel-based Virtual Machine.

Similar projects

  • React Native : Build native mobile apps using JavaScript and React
  • Ionic : Build amazing apps in one codebase, for any platform, with the web.

Encountered Problems

Cordova relies on Gradle, a build engine software My Gradle installation was provided by Android Studio but was way out of date and required a serious update. After having updated the IDE, Cordova was able to build the project and produce the expected apk file. Gradle can probably be installed on its own, but I used the Android Studio embedded one.

As a matter of fact, this wasn't that straight ! Because my Debian computers where provided with OpenJDK, I had to install Oracle's JDK. And because Oracle is the same pain in the ass as ever, installing the JDK from the package manager wasn't an option. One has to go to the Oracle Web site, look for the right package to download, check the radio-button to agree to the User Licence Agreement and then download the archive.

Decompressed in /usr/local , it was then necessary to install it as an alternative to the other Java version available on the computer. Thanks to some blogger (Pierre Gradot), I was able to do that very efficiently following his instructions.

A note about kvm

I run twice on the same problem trying to run the Hello World app in some Android virtual appliance. First, on my laptop, then on my desktop, both running Debian. My Unix user account johndoe wasn't allowed to use /dev/kvm.

To solve this, a few things must be done :

  • qemu-kvm must be installed.
  • A kvm Unix group must exist and the user johndoe must be in that group.
  • The group kvm must be assigned to the device /dev/kvm.
  • A new udev rule must be added in /etc/udev/rules.d/60-qemu-kvm.rules
apt-get install qemu-kvm cpu-checker
addgroup kvm
usermod -a -G kvm johndoe
chgrp kvm /dev/kvm

nano  /etc/udev/rules.d/60-qemu-kvm.rules
KERNEL=="kvm", GROUP="kvm", MODE="0660"

reboot

If you had to create those, then a reboot is required. Cordova should now be able to launch the Android emulator.