crashlyticsDidDetectCrashDuringPreviousExecution for crashlytics NDK
Asked Answered
M

2

1

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

Mev answered 30/3, 2017 at 8:50 Comment(0)
M
1

Mike from Fabric here.

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

Multinuclear answered 31/3, 2017 at 16:34 Comment(4)
Hey Mike, is there any update on getting callback via crashlyticsDidDetectCrashDuringPreviousExecution during relaunch for ndk?Crum
Nope, no changes.Multinuclear
@MikeBonnell with recent changes to Android and to Firebase's SDK to use Android to gather historical exit reasons firebase.blog/posts/2021/11/… developer.android.com/reference/kotlin/android/app/… according to developer.android.com/reference/kotlin/android/app/… there's developer.android.com/reference/kotlin/android/app/… available. Would these help?Wiegand
That's a great question. I no longer on Firebase or Crashlytics, so I'll leave it to the current experts to help.Multinuclear
B
1

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?

Breechcloth answered 7/6, 2018 at 16:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.