• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

App crashes *without* stacktrace - now what?

RhinoCan

Well-Known Member
How do you figure out why your app crashed if no stacktrace was written to LogCat?

I've seen the claim that all crashes of apps cause a stacktrace to be written to LogCat but I'm here to tell you that this is NOT always true. I've experienced this several times now and it's getting really annoying. I'll run my app and then get a message that the app has crashed; it advises me to click on the message and it will restart. I go to LogCat and look through it carefully - and find NOTHING. Sometimes the LogCat hasn't had anything written to it for a few minutes. I check to see if there are other threads and I just happen to be on the wrong one but usually there is just the one; even if there is another, clicking on it, doesn't change what I see: it's the exact same information for both threads.

I'm new with Android so there's a lot I don't know yet. Is this working correctly as I've described it? If it is, how is it possible to figure out my problem without a stacktrace? Are there other logs or places to check for diagnostics?

Usually I find that if I just run the app again (sometimes two or three times), it eventually starts and finally shows a stacktrace but why should that be necessary? It's just a waste of time.

I prefer to run the app without debug first to see which parts of the major functionality are working and which parts have bugs, then I can zoom in on the parts with bugs via debug.
 
Are you running your app on the phone? You're pretty stuck without a stack trace.
Run the app from Android Studio, either on the emulator, or deploy to an attached device.
 
How are you looking for the stack trace when your app crashes?

If you're using an app to look at it on your phone then you'll likely not be able to see everything you think is going on because Google/Android really (really) tightened-down the security of logcat views a good while back (and that might explain what you're seeing (or not seeing as the case may be)).

If you're using USB-corded adb logcat to view it, then you *should* be able to see everything (if you're doing that, then you might as well do what @LV426 advised above :) ).

Cheers!
 
If you're running the app from Android Studio, and it crashes, then there will be a stack trace in the Logcat view. Under some conditions however, you may need to restart the Logcat.
See this thread

https://stackoverflow.com/questions...cat-nothing-to-show?page=1&tab=oldest#tab-top

And here's the restart button:

logcat.png
 
Are you running your app on the phone? You're pretty stuck without a stack trace.
Run the app from Android Studio, either on the emulator, or deploy to an attached device.

I'm running the app on my phone with the phone connected via USB. I'm initiating the app from Android Studio.

So LogCat is the only place where I'm going to see diagnostics? There's no other place where a stacktrace or other problem might appear?
 
How are you looking for the stack trace when your app crashes?

If you're using an app to look at it on your phone then you'll likely not be able to see everything you think is going on because Google/Android really (really) tightened-down the security of logcat views a good while back (and that might explain what you're seeing (or not seeing as the case may be)).

If you're using USB-corded adb logcat to view it, then you *should* be able to see everything (if you're doing that, then you might as well do what @LV426 advised above :) ).

Cheers!

See my reply to LV426. If it doesn't answer your question, please clarify what you are asking/suggesting.
 
If you're running the app from Android Studio, and it crashes, then there will be a stack trace in the Logcat view. Under some conditions however, you may need to restart the Logcat.
See this thread

https://stackoverflow.com/questions...cat-nothing-to-show?page=1&tab=oldest#tab-top

And here's the restart button:

View attachment 134192

I wasn't aware of the need to restart Logcat or how to do it so thank you very much! I will get back into testing again in the next couple of hours and give that a try. Maybe it will finally make that stacktrace appear so I can figure out what's wrong!
 
Okay, I'm back to testing and the same thing happened: the app crashed. (Again, I was testing on my phone but initiated the test from Android Studio with the phone connected via USB. I was in normal Run mode, not debug.) I immediately clicked on Logcat and it was completely empty; I'd never seen that before! (I realize now that it was because I had a short search string in the search box and none of the existing log records containing that string.) I found the icon to restart Logcat and clicked it (with the setting at Verbose). White lines started getting written but nothing red. Then I got some red lines that were not stacktraces. Then I got a stacktrace but it was nothing to do with my app. I kept scrolling up and down in the log and several minutes after I'd restarted, I FINALLY got a stacktrace for my app. (It was weird: it seemed to be inserted a lot of lines, including my stacktrace, in the middle of the log rather than just appending it to the end. Is that normal?) Anyway, I finally have *my* stacktrace and can start fixing the bugs in my code so thanks very much!
 
Last edited:
Back
Top Bottom