Debug Android App Crash - no info in logcat, no info in console when attached

两盒软妹~` 提交于 2019-12-10 16:04:24

问题


Android Studio 1.5.1
compileSdkVersion 23

Here's what's happening:

App is attached to debugger.
I can hit breakpoints, step through code.
I have exceptions logged to the console.
I'm attempting to display a dialog fragment.

The layout xml loads properly, and I can access UI elements with findbyid...

The question is not around the specifics of this problem, and is more around why I can't seem to find any meaningful information on the crash that occurs?

I've poured over the output from adb logcat, and also had the Console open, logging all exceptions.

Nothing seems to report any info other than the alert displayed on my Android phone that the app crashed.

I've searched and all the things I've found so far point to:

a.) running in debug mode with a device (doing that)
b.) logging exceptions (doing that)
c.) checking logcat (doing that)

What else is there? I have to be missing something.


回答1:


One thing that you might try is setting an uncaught exception handler:

http://developer.android.com/reference/java/lang/Thread.UncaughtExceptionHandler.html

If you error doesn't get trapped here then it is not being thrown on the thread you think it is being thrown on, or the error is occurring outside the scope of the java exception processing mechanism.




回答2:


Crashes come in all sorts of forms (especially when you talk about Android). Hence there are a lot of ways of detecting/analyzing them.

1) Logs are usually the first thing to look at. However, you need to be sure that they are turned on for your app (production apps usually have logs turned off), so make sure they your logs actually get printed in logcat and only then look for the crash log.

2) Sometimes you have no access to logs or have no control on the component which is causing the crash. In this case, crash reports on Google Play Store can help you find out what is going wrong. However, that tool is not always easy to use or available to you (self hosted applications are a good example for that). For those cases, tools like Crashlytics are great help at getting your crash data.

3) Some crashes come from native C++ code, those are even harder to pinpoint. I found that Crashlytics and similar tools are a great help when handling with those.

4) Don't forget that sometimes the app is not really crashing, but is "gracefully" shutdown by the OS because it is hogging RAM.



来源:https://stackoverflow.com/questions/35092294/debug-android-app-crash-no-info-in-logcat-no-info-in-console-when-attached

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!