Now that you have your mobile application ready and running on Phonegap app, the next step would be to try them out on actual devices. To do that, for Android you would need to get your apk ready. This article will act as a step by step guide to accomplish exactly that on Ubuntu (I am using 14.04).

To Build The APK:

1. Add android platform specific codes, cd to the app directory and run:

You should see a “android” folder added in the app/platform directory.

2. Before you start building the apk you would need to get the setup right –

a) Install Java 8 on Ubuntu 14.04 :

b) Download the appropriate Android SDK (you need to get the one for Linux) from https://developer.android.com/studio/index.html. Unzip it in some folder.

c) Now to set JAVA_HOME, ANDROID_HOME and set PATH, open ~/.bashrc in your favorite editor and at the end of the file set the values –

Now reboot.

3. Let’s proceed to build now, go to the app directory and run –

And now you should get the apk ready in [your-app-directory]/platforms/android/build/outputs/apk as android-debug.apk. This you can install in your device to test.

NOTE:- There might be a problem at this step if you are on a 64-bit distro and have not installed the 32-bits dependencies.

PhoneGap – Android: Getting the apk
Tagged on: