Testing An Ionic Android App on a Desktop and on an Android Device

Developing an Android app via Ionic can take awhile, especially testing.  Using an emulator, for me, is out of the question because it is extremely slow.  So, what I’ve done in the past is used my own phone, connecting to the machine via USB.  But, it takes at least 10-15 seconds on my set up for Android Studio to build and run the app on my phone.

I knew there must be a way to test on a Desktop.  Ionic has a built-in server that you can run to test apps via a web browser.  To use it, you can type:

ionic serve

in a terminal window.  You need to make sure you are in the root directory of the Ionic app.  

Also, another note: one mistake I made using Ionic is that I edited my source in the android/assets/www directory using Android Studio. It turns out, this isn’t a great idea. Whenever you modify something in Ionic, say install a plugin or something, it copies the root www folder into the android www folder, thus overwriting your new code.

It turns out that using Android Studio just isn’t the best way to go to test directly on an Android device. The best way to do this is via the following commands:

ionic build android
ionic run android

I was at first skeptical that Ionic would know how to deploy to my device connected via USB…but, it does.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: