Using Google Breakpad for Android NDK?

我们两清 提交于 2019-12-03 18:59:41

问题


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 very limited and don't mention Android at all. The build system contains android information though which make me think it shouldn't be a problem.


回答1:


Sorry about that, I did the initial port but I didn't really document anything. However, one of the Chrome engineers did some work on the port and wrote a really nice README: https://chromium.googlesource.com/breakpad/breakpad/+/master/README.ANDROID

There's also an NDK-compatible Android.mk file in there now, so if you're using the standard NDK build system it should be simple to incorporate Breakpad.




回答2:


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).



来源:https://stackoverflow.com/questions/9752759/using-google-breakpad-for-android-ndk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!