Step by step guide create apk for your ionic framework project

Programmer Gamer Classic White Coffee Mug

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
[email protected] /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

Quick update youtube-dl through pip

I use youtube-dl for download video from youtube. This program is very straightforward and came with plenty of options. One day I got error message that start with ‘encrypted signature’ . After look around I was told to upgrade my youtube-dl into latest version.

$ sudo dpkg –get-selections | grep youtube
youtube-dl                    install


Since I use pip for install this software then pip install –upgrade is come to rescue.

$ sudo pip install –upgrade youtube_dl
Downloading/unpacking youtube-dl from
  Downloading youtube_dl-2015.09.22-py2.py3-none-any.whl (1.0MB): 1.0MB downloaded
Installing collected packages: youtube-dl
  Found existing installation: youtube-dl 2014.02.17
    Not uninstalling youtube-dl at /usr/lib/python2.7/dist-packages, owned by OS
Successfully installed youtube-dl
Cleaning up…

$ youtube-dl –version

Don’t update my resolv.conf

Yesterday my cousin borrow my laptop. Using guess account on my peppermint OS 5 He surf many site without hassle. This morning I got problem with dns. I see many messages around ‘dns probe no internet’ . I guess my cousin doing something with laptop but when I see my dig result i got nothing.

Try cat /etc/resolv.conf I see no nameserver beside which is common . I decide to add more entry :

# cat /etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)

save the file.

# resolvconf -d IFACE wlan0 --disable-updates


Can’t find minimal tcmalloc on DragonFlyBSD

Quick note :

— Can’t find minimal tcmalloc
ERROR: Unable to find Intel TBB install directory.
CMake Error at CMake/HPHPFindLibs.cmake:296 (if):
if given arguments:

“LESS” “5005”

Unknown arguments specified
Call Stack (most recent call first):
CMake/HPHPSetup.cmake:125 (include)
third-party/CMakeLists.txt:18 (include)
— Configuring incomplete, errors occurred!
See also “/root/hhvm/hhvm/CMakeFiles/CMakeOutput.log”.
See also “/root/hhvm/hhvm/CMakeFiles/CMakeError.log”.

To solve that error :

# pkg install google-perftools
Updating Avalon repository catalogue…
Avalon repository is up-to-date.
All repositories are up-to-date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
google-perftools: 2.4

The process will require 5 MiB more space.
621 KiB to be downloaded.

Proceed with this action? [y/N]: y
Fetching google-perftools-2.4.txz: 100% 621 KiB 79.5kB/s 00:08
Checking integrity… done (0 conflicting)
[1/1] Installing google-perftools-2.4…
[1/1] Extracting google-perftools-2.4: 100%