Debug Your Ionic App On A Device

Let us say you have created an amazing application and want to test it on a device. Now, there can be many scenarios you are unable to run. Let me take one of them. Let’s say you want to run your application and you are facing some issues with Cordova. This results in making your app no longer able to work in the browser. Also, you are tired of deploying your application to your device again and again just to check the changes you made. On some occasions, it gets very messy.

Then what to do…? How can we avoid rebuilding our application over and over again just to check our changes?

Debugging an application directly to a device makes it peaceful and cool.

Let’s start!

Things to remember

  1. You are connected with your device with USB debugging ON.
  2. Make sure you have Android studio installed.
  3. Chrome Browser (Safari if debugging with Mac)

I have taken a sample template application dream-house just to show you how we can debug; now here is my terminal below,

sample template application

Make sure your device is connected to the system and is in USB debugging mode.

“ionic cordova run android --device -l --debug”

This is the command that allows you to debug it over a device.

Debug Your Ionic App On A Device

It has now started running, you now can open the app on the device.

Now, go to Chrome, go to inspect element (shortcut is Ctrl+Shift+i).

Click on the 3 dots menu.

Debug Your Ionic App On A Device

Now, navigate to More tools > Remote Devices.

Debug Your Ionic App On A Device

You can find your device connected.

Debug Your Ionic App On A Device

Click on your device, (mine is ONEPLUS A6000).

Debug Your Ionic App On A Device

Click on Inspect; a popup will open where you will see the emulator kind of screen for the device.

Debug Your Ionic App On A Device

That has successfully debugged your application on the device. The controls follow the same on your device as you process in emulator and vice versa … enjoy coding.

Note
If you are working with a Mac machine, then use the following -

Open Safari >Develop Menu >my device >my ip address.


Similar Articles