7

I have a Cordova app that compiles with no errors. However, when I lunch the app to my android device it instantly crashes on startup. I am having a hard time debugging 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.

3
  • Search how to collect and check "Force Close" via LOGCAT
    – guipivoto
    Jul 11, 2016 at 13:34
  • @Guilherme P is there a specific article you can recommend?
    – Tim
    Jul 11, 2016 at 13:36
  • See this SO answer: stackoverflow.com/a/32115428/1814840 for instructions on getting the error from logcat Jul 11, 2016 at 14:03

2 Answers 2

11

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.

Capturing

Basically, you can capture logcat with following command:

adb logcat

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.

Analyzing

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:

  • When the issue happened: 07-09 08:29:13.475

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 :)

  • Which app crashed: com.example.khan.abc

This way, you know which app crashed (to be sure that you are checking the logs about your message)

  • Which ERROR: java.lang.NullPointerException

A NULL Pointer Exception error

  • Detailed info about the 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).

    at com.example.khan.abc.AudioFragment$1.onClick(AudioFragment.java:125)

Error happened in file com.example.khan.abc.AudioFragment.java, inside onClick() method at line: 125 (stacktrace shows the line that error happened)

It was called by:

at android.view.View.performClick(View.java:4848)

Which was called by:

at android.view.View$PerformClick.run(View.java:20262)

which was called by:

at android.os.Handler.handleCallback(Handler.java:815)

etc....

Overview

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

0

• Delete the existing folder of MFP Named as : cordova-plugin-mfp (Older Version of MFP Plugin)

• Now run this command and installed the latest version of mfp – “ cordova plugin add [email protected]

• Now recheck the version by navigating to this path and opening Plugin.xml file inside the mfp folder : D:*******8\FMB_1128_MFP8\plugins\cordova-plugin-mfp\plugins.xml

• You will see the version like this : version="8.0.2018112111" here 8.0 Stands for MFP-8 : 2018: Year of Update: 11:Month of update

By doing these following steps, you will fix the crash issue of the app over android-p version –‘9’

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.