Question

Sometimes my application crashes while trying to open it. As the app hasn't completely started I don't get an error report. I also can't connect my application to the emulator because this behaviour is not reproducable. Sometimes it just crashes once. In other times I can try to open/reopen it as often as I want and it works perfect.

I only use the network-connection (no camera and other stuff). I don't have any services which could crash the application and I tried to reproduce my error by trying to stop the application while it loads something in the background - no success at all.

What do you think could be the reason for crashing? How can I get a log-file, stacktrace something useful for fixing this problem? I simply can't reproduce it so I never see a Logcat-Output when it occurs.

It might be a Fragment-Initializing-Problem but I can't see my mistake. This never occured before and it's just not a common mistake. It might crash only once/twice a week - but it crashes in some point in time...

I've uploaded my project on github but I don't think this is helping somehow.

My main question is: What for opportunities do I have to see what might be the reason behind these random crashes?

Was it helpful?

Solution

Root your phone and install CatLog. When it crashes, open CatLog and save the log so you can view it later.

Or try this if you want to automate it:

Create an exception handler that saves a stack trace to a file.

public class UncaughtExceptionSaver implements UncaughtExceptionHandler{

    UncaughtExceptionHandler previousHandler;
    Context context;

    public UncaughtExceptionSaver (Context context){
        this.context = context;
        previousHandler= Thread.getUncaughtExceptionHandler();
    }

    @Override
    void uncaughtException(Thread t, Throwable e){

        /*Save the stacktrace from the throwable to a 
          file in your external directory, using context. */

        previousHandler.uncaughtException(t,e);
    }
}

Then in an Application subclass, call this in the onCreate method:

Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionSaver(this));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top