Android Development under generic linux OS using Cordova

Jump to navigation Jump to search

Download requirements

Choose paths with user permissions

  • this can saved in ~/.bashrc:
export SHARED_PATH=/home/shared
export ANDROID_SDK_HOME="${SHARED_PATH}/opt/android-sdk";
export PATH="${ANDROID_SDK_HOME}/platform-tools:${ANDROID_SDK_HOME}/tools:${PATH}";

export NODEJS_HOME="${SHARED_PATH}/opt/nodejs";
export PATH="${NODEJS_HOME}/bin:${PATH}";

Install Android SDK locally

tar -xzf android-sdk_r24.3.2-linux.tgz;
mv android-sdk-linux "${ANDROID_SDK_HOME}";

Prepare Android SDK

  • run follow:
  • Install:

- "Tools -> Android SDK Plataform-tools"

- "Tools -> Android SDK Build-tools"

- "Android 5.1.1 API -> SDK Plataform"

- "Extras -> Android Support Library"

Install nodejs locally

mkdir -p "${NODEJS_HOME}";
tar -xzf node-v0.12.4-linux-x64.tar.gz;
mv node-v0.12.4-linux-x64/* "${NODEJS_HOME}";
rmdir node-v0.12.4-linux-x64;

Configure npm to ignore invalid self-signed certificate error (if needed)

npm set strict-ssl false

Install cordova globally

  • Warning, actual cordova 5 only support android version >= 4.0

npm install -d -g cordova;

  • to run on android 3.x you should use cordova 4.x

npm view cordova versions;
npm install -d -g cordova@4.0;

  • to run on android 2.2.* you should use cordova 2.9.x

npm view cordova versions;
npm install -d -g cordova@2.9.7;

Enable Developer Option and USB debugging

Test an hello-world project

cd ~/;
cordova create hello com.example.hello HelloWorld;
cd hello;
# for cordova 5.x and android >= 4.0
cordova platform add android;
# else, for cordova 4.x and android >= 3.x
cordova platform add android@3.5.0
cordova build android;
cordova run android --device;