debug android app with ionic- cordova

24,516

Solution 1

If you run your app in the livereload mode you will see the console.log() messages. You can start it like this:

ionic run android -l 

You can also use chrome developer tools like it would be a normal webpage. Here is good description how you achieve that: Remote Debugging on Android with Chrome

Solution 2

  1. Connect with an android device which has Android OS version >= 5

  2. Enable developer option from the settings. This procedure varies from device to device. In addition you must enable USB debugging mode from developer option or from other section of your device.

  3. If you get any error like “Your device is not connected” from Android SDK or Android studio then find out the problem from your device manager of pc. Most of the time appropriate driver or driver is not installed in the machine. Download it and follow my instruction in a video (Yafi Tech).

  4. Run the command ionic cordova run android. APK is built and installed in the device. done

  5. run “chrome://inspect” in the chrome status bar. Remote debugging of connected device has been started.

  6. Now run the installed application and operate from the device or chrome.

  7. Click on inspect of WebView. For debugging Go to the console of browser if you want to trace out any error.

you can also watch video here

Solution 3

Now that there is a livereload option (-l), to see the console.log messages you have to use -c or --consolelogs But to have logs, the livereload option is required so :

ionic run android -lc

See the documentation for more options : http://ionicframework.com/docs/v1/cli/run.html

Solution 4

The Ionic CLI has been updated for ionic 2+ to deploy app in live reload mode use the following command.

Synopsis

$ ionic cordova run <platform> <options>

Example

$ ionic cordova run android -l -c

Make sure that you have installed the latest version of Ionic/Cordova CLI

Solution 5

with Ionic 5 and cordova 9 use:

ionic cordova run android -l --consolelogs

where -l is for livereload

Share:
24,516
ן123456
Author by

ן123456

Updated on July 09, 2022

Comments

  • ן123456
    ן123456 almost 2 years

    There is a way to debug? I use

    ionic run android
    

    command to run the app on android but then - how can I see console.log() messages?

    Thanks