Installation

Download from http://developer.android.com/sdk/index.html

_$: mv android-sdk_r24.4.1-linux.tgz $HOME/<usuario>/apps/
_$: cd $HOME/<usuario>/apps/
_$: tar xvfz android-sdk_r24.4.1-linux.tgz

Install Android tools

_$: cd android-sdk-linux/tools
_$: ./android

Build the application

_$: cd .../<phonegap application>
_$: export ANDROID_HOME=$HOME/apps/android-sdk-linux
_$: cordova platform add android
_$: cordova platform ls
Installed platforms: android 5.1.0, browser 4.0.0
Available platforms: amazon-fireos, blackberry10, firefoxos, ubuntu, webos
_$: phonegap build android --release
[phonegap] executing 'cordova build android --release'...
[phonegap] completed 'cordova build android --release'

_$: find . -name "*.apk"
./platforms/android/build/outputs/apk/android-release-unsigned.apk

Sign and compress the application

Create the signing key:

_$: keytool -genkey -v -keystore mobile-app.keystore -alias mobile_app \
  -keyalg RSA -keysize 2048 -validity 365

Sign the application:

_$: APK_DIR="./platforms/android/build/outputs/apk"

_$: jarsigner -verbose \
  -sigalg SHA1withRSA -digestalg SHA1 \
  -keystore mobile-app.keystore \
  ${APK_DIR}/android-release-unsigned.apk mobile_app

Check it has been properly signed:

_$: jarsigner -verify -verbose -certs ${APK_DIR}/android-release-unsigned.apk

Compress the application:

_$: zipalign="/home/dceresuela/apps/android-sdk-linux/build-tools/23.0.2/zipalign"

_$: ${zipalign} -v 4 ${APK_DIR}/android-release-unsigned.apk mobile_app.apk

Download the application

If we still have the DNS server configured to test the PhoneGap applications, we can download it directly from the development server. To do so, we will run an HTTP server which will list the files in the folder.

_$: cd ${APK_DIR}
_$: python -m SimpleHTTPServer 8080

From the smartphone we go to pg.tl.tl:8080 and download the application. When the downloaded has finished, install it.