Step by step guide create apk for your ionic framework project

I just learn to use ionic framework and I like it since I can use my knowledge in html and css a bit. The process also push me to learn about angular js. As the process getting fun each day I got litttle problem with create apk process (part of publishing). Specially in sign step. I try to recreate it by make simple ‘blank’ project.

Here’s my environment :

$ ionic info

Your system information:

Cordova CLI: 5.3.1
Gulp version:  CLI version 3.9.0
Gulp local: 
Ionic CLI Version: 1.6.5
Ionic App Lib Version: 0.3.9
OS: Distributor ID:    Peppermint Description:    Peppermint Five
Node Version: v4.0.0

Create the project

$ ionic start test blank

$ cd test/

$ ionic platform add android

Start process build apk

$ cordova plugin rm cordova-plugin-console

$ cordova build –release android





Total time: 13.138 secs
Built the following apk(s):

Generate Private Key

I use this convention :

keytool -genkey -v -keystore appname.keystore -alias appnamekey -keyalg RSA -keysize 2048 -validity 10000

$ keytool -genkey -v -keystore test.keystore -alias testkey -keyalg RSA -keysize 2048 -validity 10000
Enter keystore password: 
Re-enter new password:
What is your first and last name?
  [Unknown]:  alamsyah rasyid
What is the name of your organizational unit?
  [Unknown]:  digitalfusi
What is the name of your organization?
  [Unknown]:  digitalfusi
What is the name of your City or Locality?
  [Unknown]:  palembang
What is the name of your State or Province?
  [Unknown]:  sumsel
What is the two-letter country code for this unit?
  [Unknown]:  id
Is CN=alamsyah rasyid, OU=digitalfusi, O=digitalfusi, L=palembang, ST=sumsel, C=id correct?
  [no]:  yes

Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,000 days
    for: CN=alamsyah rasyid, OU=digitalfusi, O=digitalfusi, L=palembang, ST=sumsel, C=id
Enter key password for <testkey>
    (RETURN if same as keystore password): 
[Storing test.keystore]

Sign apk file

1st error :

$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore test.keystore android-release-unsigned.apk test
Enter Passphrase for keystore:
jarsigner: Certificate chain not found for: test.  test must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain.

note : I don’t use absolute path for this command.

2nd error :

$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore /home/alamsyah/test/test.keystore android-release-unsigned.apk testkey
Enter Passphrase for keystore:
jarsigner: unable to open jar file: android-release-unsigned.apk

note : I type the command not in the same location of .apk file

$ cd platforms/android/build/outputs/apk/

retype the command

$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore /home/alamsyah/test/test.keystore android-release-unsigned.apk testkey
Enter Passphrase for keystore:
  signing: AndroidManifest.xml
  signing: assets/www/cordova-js-src/android/nativeapiprovider.js
  signing: assets/www/cordova-js-src/android/promptbasednativeapi.js
  signing: assets/www/cordova-js-src/exec.js
  signing: assets/www/cordova-js-src/platform.js
  signing: assets/www/cordova-js-src/plugin/android/app.js
  signing: assets/www/cordova.js
  signing: assets/www/cordova_plugins.js
  signing: assets/www/css/style.css
  signing: assets/www/img/ionic.png
  signing: assets/www/index.html
  signing: assets/www/js/app.js


signing: classes.dex
jar signed.

No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate this jar after the signer certificate’s expiration date (2043-02-17) or after any future revocation date.

Optimize apk with zipalign

zipalign is part of jdk. In my case I already install it in /opt

$ pwd
alamsyah@alamsyah-HP-Pavilion-14-Notebook-PC /opt/android-sdk/build-tools/23.0.1 $ ls
aapt  arm-linux-androideabi-ld  dexdump  i686-linux-android-ld  jill.jar  llvm-rs-cc      mainDexClasses.rules     NOTICE.txt  split-select
aidl  bcc_compat                dx       jack.jar               lib       mainDexClasses  mipsel-linux-android-ld  renderscript   zipalign

So the correct command is :

$ /opt/android-sdk/build-tools/23.0.1/zipalign -v 4 android-release-unsigned.apk  test.apk
Verifying alignment of test.apk (4)…
      50 META-INF/MANIFEST.MF (OK – compressed)
    3297 META-INF/TESTKEY.SF (OK – compressed)
    6633 META-INF/TESTKEY.RSA (OK – compressed)
    7806 AndroidManifest.xml (OK – compressed)
    8974 assets/www/cordova-js-src/android/nativeapiprovider.js (OK – compressed)
    9752 assets/www/cordova-js-src/android/promptbasednativeapi.js (OK – compressed)



2295604 res/drawable-xhdpi-v4/icon.png (OK)
 2302852 res/drawable-xxhdpi-v4/icon.png (OK)
 2314932 res/drawable-xxxhdpi-v4/icon.png (OK)
 2331845 res/xml/config.xml (OK – compressed)
 2333704 resources.arsc (OK)
 2337101 classes.dex (OK – compressed)
Verification succesful.

That is good sign that apk successfully optimize and ready for google play :-)

 ls -l | grep apk
-rw-rw-r– 1 alamsyah alamsyah 2402681 Okt  2 16:46 android-release-unsigned.apk
-rw-rw-r– 1 alamsyah alamsyah 2402707 Okt  2 16:50 test.apk

Trying Eclipse on Ubuntu 13.04

I want to try Eclipse on my Ubuntu 13.04 . Installation process is quite straight perhaps useful for me in future use.

Checking Java

I already install Java before, check it first :

$ java -version

java version “1.7.0_25”
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)
OpenJDK Server VM (build 23.7-b01, mixed mode)

Get nearest mirror from Eclipse website

As I’m from Indonesia I got mirror from University of Indonesia.

$ wget -c

Checking md5 sum against :

bd98e1ac83cbc95909a3c856d3ced8a6  eclipse-standard-kepler-SR1-linux-gtk.tar.gz

$ md5sum eclipse-standard-kepler-SR1-linux-gtk.tar.gz
bd98e1ac83cbc95909a3c856d3ced8a6  eclipse-standard-kepler-SR1-linux-gtk.tar.gz

Good packet.

$ tar xvzf eclipse-standard-kepler-SR1-linux-gtk.tar.gz

$ sudo ln -s /home/alamsyah/eclipse/eclipse /usr/bin/eclipse
[sudo] password for alamsyah:


$ sudo nano /usr/share/applications/eclipse.desktop

[Desktop Entry]
Comment=IDE for all seasons
Exec=env UBUNTU_MENUPROXY=0 /home/alamsyah/elipse/eclipse


Add ADT Plugin

Start eclipse by typing : eclipse . Click Help and Install New Software.

Click Add button and enter :

Name : ADT

Url :



Click Next.


Accept Terms.


Choose ‘Always run in background’.



Installing Android SDK on Ubuntu Desktop 13.04

I want to learn about Android application and heard about phonegap. Android SDK is a must have before proceed to next step. Here my documentation for install android SDK on my Ubuntu Desktop 13.04 :

Get latest SDK Tools, minimalist is better. I pick SDK Tools only.

After get the link via firefox I decide to use wget :

$ wget -c
$ mv android-sdk_r22.3-linux.tgz /home/alamsyah/
$ cd /home/alamsyah/
$ tar xvzf android-sdk_r22.3-linux.tgz

update path ::

$ export PATH="$HOME/android-sdk-linux/tools:$HOME/android-sdk-linux/platforms:$PATH"

$ echo $PATH


install jdk and  ant

$ sudo apt-get install openjdk-6-jdk ant


Click Install 9 Packages button to continue and get rid of “missing platform tools” error message.


After install remaining packages then the path need to adjust :

Last one need to install related to Android SDK is : android debug bridge
$ sudo apt-get install android-tools-adb

Enough :-)