How can I see console errors on a phone?

Imported Question by estelle · Sep 30, 2016 at 09:41 AM

If the app is not working on my phone, how can I get more info about what is wrong?

To see the console errors on a phone, follow these instructions, up to selecting your device.

Then select MedicMobile’s WebView in the list (you need to have MedicMobile app open and running in the foreground), by clicking “inspect”!

This opens the DevTools.

Click the “Console” tab in the DevTools. Errors should be there.

b

2 Likes

A simpler way having Java and the Android SDK installed (Android Studio is not required) is to see the logs from Logcat, the logging system from Android.

Both logs from the Java code of the app and logs from the Javascript code of the Webapp (CHT-Core) are shown.

Connect the phone to the computer where is installed the SDK, and execute within the command line:

$ adb logcat MedicMobile:V AndroidRuntime:E '*:S'

NOTE: you have to have configured your phone in debug mode, and have previously linked your phone with your development environment. if you have the source code of the cht-android app, you can just execute instead:

$ make logs

@mrsarm where should I see the logs after running this? I have run the unbranded_testXwalkDebug variant on my device from AndroidStudio and then (with the device still connected) I ran that command and got this output:

$ adb logcat MedicMobile:V AndroidRuntime:E '*:S'
--------- beginning of crash
--------- beginning of system
--------- beginning of main

The process continues running in the terminal, but I do not see any logging there (or any extra looking in the Android Studio Run pane).

Also, just want to note for the record that the DevTools method that Gareth mentions above does not work if you are trying to use a modern version of Chrome to get the logs for the Xwalk variant. However, I was able to successfully use the DevTools from Chromium 75.0.3770.100 to get the logs.

Thanks @jkuester , and I’m posting here other findings that you an me got after talk through other channels.

First, if the logcat command suggested above doesn’t work, might be that the output format is different. So worth to try instead:

adb logcat MedicMobile:V AndroidRuntime:E chromium:V '*:S'

Or a simpler solution could be get all the logs and filter out with grep:

adb logcat | grep MedicMobile

If you still don’t see anything, worth to check the phone and adb are in sync, so check that your phone is listed when executing adb devices. If so, also check that your are able to see all the logs of your phone with adb logcat.

1 Like