Recent Changes - Search:




How to test an App in Android

To run your App in an Android device (even when you are not connected to the Internet), you need to do the following:

  1. Build the IONIC code specific for the Android platform
  2. Use Android Studio to compile this code for the Android platform
  3. Test on your Android device
  4. Alternatively, generate a self-contained APK file
  5. Eventually, put your App in the Google App Store

Before we begin, please download and install in your computer the Android Studio environment. This environment contains all the programming utilities required to create Android apps (even from scratch). Follow the instructions in this link. Android Studio is large (some 700 or 800 Mb), so be patient.

1. Build the IONIC code specific for the Android platform

For this, type ionic cordova build android. This process can produce a number of errors if you did not install the Android Studio (as we told you to do!) It can also require that you install a number of additional packages. Just do it.

When successful, the process will create a subfolder of your project folder platforms, called android.

2. Use Android Studio to compile this code for the Android platform

Open Android Studio in your computer and choose the option Open an existing Android Studio project. Select the android folder as the 'existing Android Studio project'. (Android Studio may ask you to install some other things... accept.)

This will open your project and automatically build it (compile it for Android).

3. Test on your Android device

This requires a number of preliminary adjustments in your device (phone or tablet). But, once they are done, testing is as simple as connecting the device to your computer and running the Android Studio project, selecting your device as target.

Here is the list of adjustments to make:

  • Enable Development Mode in your device. In your device (phone or tablet) go to Settings -> About phone -> Software Information and then click several times on Build number. After several times, the device enables Development mode. A new Developer options entry will appear at the bottom of the Settings menu.
  • Enable USB debugging. Enter Settings -> Developer options and turn on USB debugging. The device may ask for confirmation.

Your device is now ready. Connect it with a USB cable to your computer and in Android Studio click Run -> Run app. A dialog will show that your device is connected, selected it and click OK. The app should run in your device.

In some cases (we've experienced this on a Windows system), the device is not recognised. In this case, you need to install a driver for your device. Visit this page for instructions and finding your driver.

4. Alternatively, generate a self-contained APK file

On Android Studio, click on Build -> Build APK(s). This will generate a file ending in .apk. Open it from your device. (You can, for instance, put it in your Dropbox folder and open it from the device.)

When you open it, Android recognises it is an app, and will issue a message asking if you want to install this application. Install it and that is all.

5. Eventually, put your app in the Google Play Store

This is a standard procedure and is beyond the scope of these instructions. Here are some hints and llinks:

  • First generate a release version of your app: ionic cordova build android - - release
  • Read the instructions in this page:
  • Note by Loo Kang Wee: to overcome the zipalign problem with submitting to Google Play store, try to download earlier versions of Android SDK and copy the file zipalign.exe to the same directory of SDK23 depending on which latest version of the SDK you are using to compile the apk. It should work but it is not tested yet by @lookang

Edit - History - Print - Recent Changes - Search
Page last modified on July 27, 2018, at 03:43 AM