If you want to learn, how to deploy the developed Ionic 2 application on your Android device without publishing to the Play Store, then you are in the right tutorial.

You can preview and test your Ionic 2 application using

1. Browser (ionic serve --lab)
2. Ionic View App(ionic upload)
3. Emulators(Genymotion for Android and Xcode for iOS)
4. Physical Device(Android and iPhone)

Please note: You can not directly install and test your app on iPhone. But you can directly install and test your app on Android. iPhone doesn't allow apps which are not published on the App Store.


In this tutorial, you will learn, how to deploy the developed Ionic 2 Android app on the Android Mobile Phone. I am not going to write more theory about this process. Let see how to do this in simple steps.

The below software example and codes are tested with the MacOS Sierra and Moto G4 Plus(Android Phone).

Step1:

Install Java

Step2:

Install Android Studio

You can use the below link to learn, to setup the Android on MacOS Sierra.

https://ampersandacademy.com/tutorials/ionic-framework-version-2/setup-android-studio-and-generate-apk-in-mac-os-sierra

Step3:

Set Android platform to the terminal using the below code.

export PATH="/YourLocation/Android/sdk/platform-tools":$PATH

Replace the YourLocation with your actual Android installed location.

If you don't know the location of the installed Android, open the Android Studio and click the SDK Manager.

From the below image you can able to find the installed Android Location.

Everything is ready in the System/laptop. Now you need to ready your Android device.

Enable Developer option on your Android device.

Step1:

Go to settings and click the About Phone.

Step2:

Click the Build Number five times continuously to enable the developer option on your Android device.

Step3:

Now click the Developer options on the settings page.

Step4:

Enable the USB debugging option

Now connect your Android phone to the Mac OS through USB cable.

To list the available Android device use the below command in the terminal.

adb devices

The above command will display the connected device information.

That's all. All done. Now you are ready to deploy and test the developed Ionic 2 mobile application on your Android device.

Now go to your Ionic 2 project root directory on the terminal.

cd ionic2_proj_name

Add the Android platform using the below command.

ionic platform add android

Deploy the app using the below command.

ionic run android

Now the Ionic 2 app is deployed on your Android device. Enjoy testing the application on your Android phone.

Conclusion:

Every Ionic 2 developer wants to test their application on the physical device. This tutorial focuses the Android deployment only. Why because iPhone does not allow this kind of deployment. To test the iOS applications on the iPhone, you must sign-in and upload the developed application to the App Store(https://developer.apple.com). 

To know more about the iOS test flight(Beta Testing), use the below link.

https://developer.apple.com/testflight/