Search code examples
androidioscordovadebuggingionic-framework

Is there a way in Ionic to debug directly on Android or iOS devices?


I'm working on an Ionic/Cordova cross-platform application and I'm struggling a little bit with the debugging. Debug can of course be done directly from the browser by running ionic serve and then using the browser developer tools, but some behaviors happen only on real devices.


Solution

  • Adding a detailed guide to do this..

    1. Make sure your android device has Developer mode on, and USB debugging is enabled in the developer settings on your device. You can google to activate this.
    2. Device connected via USB, both system and mobile device connected to same wifi network..Use command

    ionic cordova run android -l --external

    1. After app has installed and started up on device, open this link in your chrome browser

    chrome://inspect/#devices

    1. If all was done correctly, you will see your device name and app name there with an option to inspect. This will open the chrome developer console exactly similar to the web one.

    2. Now you can debug the app right on the device. Add breakpoints, edit html and see the logs as well.

    Reference