ן123456
ן123456

Reputation: 175

debug android app with ionic- cordova

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

Upvotes: 11

Views: 26146

Answers (8)

ward
ward

Reputation: 11

with Ionic 5 and cordova 9 use:

ionic cordova run android -l --consolelogs

where -l is for livereload

Upvotes: 1

Abhay Singh
Abhay Singh

Reputation: 1689

Connect your android device to computer/laptop and simply run below command

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

Upvotes: 0

Vagner Gon
Vagner Gon

Reputation: 645

If you want a real debug, with watches, step into, etc, try the Cordova Tools extension for Visual Studio Code

The page constains the instructions for debuging on device.

Upvotes: 0

Yusuf
Yusuf

Reputation: 743

  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

Upvotes: 5

Anoop M Maddasseri
Anoop M Maddasseri

Reputation: 10549

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

Upvotes: 2

Godineau F&#233;licie
Godineau F&#233;licie

Reputation: 438

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

Upvotes: 2

Muhammad Arslan
Muhammad Arslan

Reputation: 91

From ionic doc ionic run ios [options] http://ionicframework.com/docs/cli/run.html

Upvotes: -4

andreaspfr
andreaspfr

Reputation: 2314

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

Upvotes: 19

Related Questions