pavodev
pavodev

Reputation: 33

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.

Upvotes: 3

Views: 7811

Answers (4)

Yevhenii Ostash
Yevhenii Ostash

Reputation: 41

for Android you could open chrome://inspect/#devices (emulator/real device), then click inspect on needed webview. IOS you could open safari Develop=>needed device(real/emulator) => choose needed application.safari=>develop=>device=>app

Upvotes: 0

Juan Antonio
Juan Antonio

Reputation: 2614

A simple way could be using logcat, take a look to this answer Debugging a WebView (Ionic) app on Android via logcat.

Upvotes: 0

Chetan Bansal
Chetan Bansal

Reputation: 1934

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

Upvotes: 7

Thomas
Thomas

Reputation: 8859

Yes, you can use Chrome and Safari DevTools to connect to your device and debug the HTML/JS/CSS, as long as you don't build a release version (cordova build android ---release). It does take some initial setup since it's disabled by default.

Or you can use Android Studio or XCode to debug the plugins etc.

Note that you can only debug iOS apps with a Mac (or using Google's iOS WebKit Debug Proxy). Android apps can be debugged from any OS with Chrome (for HTML/JS/CSS) or Android Studio installed.

Official Cordova debugging guide

Upvotes: 2

Related Questions