Oded Maimon
Oded Maimon

Reputation: 11

crashlyticsDidDetectCrashDuringPreviousExecution for crashlytics NDK

We are using crashlyticsDidDetectCrashDuringPreviousExecution to detect java crashes and report them to our BI systems, but our app is mostly C++ and we are using crashlytics NDK, we can't find anything similar to crashlyticsDidDetectCrashDuringPreviousExecution.

Is there any way that we can actually detect an NDK crash when the app starts?

thanks Oded

Upvotes: 1

Views: 596

Answers (2)

brkeyal
brkeyal

Reputation: 1385

NOTE: This works on older version only (Crashlytics 2.6.7 and CrashlyticsNDK 1.1.6)

I'm also looking for a solution for this. We currently found a partial solution. I'm not sure how good it is, it's definitely not official, plus it's asynchronic (which we're trying to overcome by looping), but it's the best solution I found and it seems like it's working

Fabric.with(this, new Crashlytics.Builder().core(core.build()).build(), new CrashlyticsNdk(), new Crashlytics());
if (!userLeft) { // our handling to fix bug, see explanation below
    new Thread(new Runnable() {
        @Override
        public void run() {
            SessionEventData crashEventData = null;
            for (int i = 0; i < 10; i++) {
                try {
                    Thread.sleep(1000); // in ms
                } catch (InterruptedException e) { }

                crashEventData = CrashlyticsNdk.getInstance().getCrashEventData();
                if (crashEventData != null)
                {
                    // there was a crash!
                    // crash timestamp can be found at crashEventData.timestamp
                    break;
                }
            }
        }
    }).start();
}

Explaination for userLeft:

We had some bug with reporting crash for users that exited app, and this is the solution for that. We set this flag to true, and save it on the device (SharedPreferences). We do it on our main activity (which extends NativeActivity), on finish() func. Code:

@Override
public void finish() {
    // set some key such as USER_LEFT to TRUE
    super.finish();
}

After that, just get that USER_LEFT value, assign it into userLeft param, and set it back to false on SharedPerferences.

Any insights about this solution?

Upvotes: 1

Mike Bonnell
Mike Bonnell

Reputation: 16249

Mike from Fabric here.

Currently, there isn't a way to do this within Fabric or the SDK for an NDK crash.

Upvotes: 1

Related Questions