Setting up Ubuntu Trusty for Apache Cordova Android development
Assuming you're on 64-bit Ubuntu, this may be necessary:
sudo apt-get install libgl1-mesa-dev:i386 libgl1-mesa-dev
The nodejs and node-js legacy in the Ubuntu repos are flaky and not recommended, so remove them if they're installed; then
- sudo apt-get install ant ant-contrib ant-optional ant-gcj
- sudo apt-get install npm
- sudo apt-add-repository ppa:chris-lea/node.js
- sudo apt-get update && sudo apt-get install nodejs
- Download the Android ADT Bundle and put it in a likely location such as $HOME/adt-bundle-linux-x86_64.
- Edit ~/.bashrc and add:
export PATH=$PATH:/usr/share/npm/bin export ANDROID_HOME="/home/mholmes/adt-bundle-linux-x86_64/sdk/tools" export ANDROID_PLATFORM_TOOLS="/home/mholmes/adt-bundle-linux-x86_64/sdk/platform-tools" export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH" export ANT_HOME="/usr/share/ant" export PATH="$PATH:$ANT_HOME/bin"
Run "android" at the command line to start the Android SDK manager, and install any updates. Also install the latest Android version (the highest API number), all components.
Next, start the Eclipse IDE that comes with the Android developer tools and create an AVD emulator (Windows/Android Virtual Device Manager). Use the default settings for a Nexus 4; Nexus 5 emulators fail to start, for some reason. This emulator will be available in Cordova to run your app. Set up the emulation based on the Android version you installed in the step above. Starting it the first time can take several minutes.
Now create a new project in Cordova at the command line:
cordova create test com.mholmes.test TestApp
Add the Android platform to the project:
cd test cordova platform add android
and finally try building and running the project in the emulator:
cordova emulate android