I have a Cordova app that compiles with no errors. When I lunch the app to my android device it instantly crashes on startup. I am having a hard time to debug when I do not know what the bug is…
QUESTION: Is there a way to get the error report from this crash?
I usually use chrome to debug my app but that only works if the app is able to load and run on the device.
You requested some article about logcat... I'm putting in the answer section since it is too much information for comments :)
DOCS In case of Android, you can always go to Developer's page.
HERE is the Android's page about logcat
If you use android Studio, you can also check this LINK.
Basically, you can capture logcat with following command:
There's a lot of parameters you can add to command which helps you to filter and display the message that you want... This is personal... I always use the command below to get the message timestamp:
adb logcat -v time
You can redirect the output to a file and analyze it in a Text Editor.
If you app is Crashing, you'll get something like:
07-09 08:29:13.474 21144-21144/com.example.khan.abc D/AndroidRuntime: Shutting down VM 07-09 08:29:13.475 21144-21144/com.example.khan.abc E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.khan.abc, PID: 21144 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v4.app.FragmentActivity.onBackPressed()' on a null object reference at com.example.khan.abc.AudioFragment$1.onClick(AudioFragment.java:125) at android.view.View.performClick(View.java:4848) at android.view.View$PerformClick.run(View.java:20262) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5631) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754) 07-09 08:29:15.195 21144-21144/com.example.khan.abc I/Process: Sending signal. PID: 21144 SIG: 9
This part of the log shows you a lot of information:
It is important to check when the issue happened... You may find several errors in a log... you must be sure that you are checking the proper messages :)
This way, you know which app crashed (to be sure that you are checking the logs about your message)
A NULL Pointer Exception error
Attempt to invoke virtual method 'void android.support.v4.app.FragmentActivity.onBackPressed()' on a null object reference
You tried to call method
onBackPressed() from a
FragmentActivity object. However, that object was
null when you did it.
Stack Trace: Stack Trace shows you the method invocation order... Sometimes, the error happens in the calling method (and not in the called method).
Error happened in file
onClick() method at line:
125 (stacktrace shows the line that error happened)
It was called by:
Which was called by:
which was called by:
This was just an overview... Not all logs are simple etc... It is just to share the idea and provide a entry-level information to you...
I hope I could help you someway... Regards