Using Google Breakpad for Android NDK?

后端 未结 2 352
梦如初夏
梦如初夏 2020-12-28 17:26

Is anyone using Google Breakpad for Android native code (NDK) ?

If so, could you elaborate on how to get it up and running (the client side that is). The docs are ve

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-28 17:52

    I also found a good example project for that. As it is in the project you can set up Google Breakpad like:

    extern "C" {
        void Java_com_pluusystem_breakpadjavacall_MainActivity_initNative(JNIEnv* env, jobject obj, jstring filepath)
        {
            const char *path = env->GetStringUTFChars(filepath, 0);
            google_breakpad::MinidumpDescriptor descriptor(path);
            exceptionHandler = new google_breakpad::ExceptionHandler(descriptor, NULL, DumpCallback, NULL, true, -1);
        }
    }
    

    in the cpp side and like:

        // Save Dump Path
        initNative(getExternalCacheDir().getAbsolutePath());
    

    in the java side.

    After that implementing the bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void* context, bool succeeded) function you will be able to do something before the app crashes.

    I have experienced and also found this issue which confirms me, that in this function you can't do java callbacks under ART just under DVM (before android 5 - Lollipop).

提交回复
热议问题