Skip to content Skip to sidebar Skip to footer

Using Google Breakpad For Android Ndk?

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

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

Solution 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" {
    voidJava_com_pluusystem_breakpadjavacall_MainActivity_initNative(JNIEnv* env, jobject obj, jstring filepath){
        constchar *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 PathinitNative(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).

Solution 3:

My example repo for Flutter Android/iOS: https://github.com/Sunbreak/flutter-breakpad.trial


Android

$NDK is local path of your Android NDK directory

$CLI_BREAKPAD is local clone of https://github.com/Sunbreak/cli-breakpad.trial

cd$BREAKPAD/src/android
cp -r google_breakpad jni
$NDK/ndk-build
  • Install libbreakpad_client.a of all architectures
mkdir -p ./android/app/src/main/cmakeLibs
cp -r $BREAKPAD/src/android/obj/local/* ./android/app/src/main/cmakeLibs/
  • run on macOS/Linux
# Device/emulator connected
$ android_abi=`adb shell getprop ro.product.cpu.abi`
$ flutter run
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
I/flutter_breakpad(31631): JNI_OnLoad
D/flutter_breakpad(31631): Dump path: /data/data/com.example.flutter_breakpad/files/f5258c0e-eff3-433a-7ea47880-c756fc17.dmp
$ adb shell "run-as com.example.flutter_breakpad sh -c 'cat /data/data/com.example.flutter_breakpad/files/f5258c0e-eff3-433a-7ea47880-c756fc17.dmp'" >| libflutter-breakpad.so.dmp
$ $CLI_BREAKPAD/breakpad/linux/$(arch)/dump_syms build/app/intermediates/cmake/debug/obj/${android_abi}/libflutter-breakpad.so > libflutter-breakpad.so.sym
$ uuid=`awk 'FNR==1{print \$4}' libflutter-breakpad.so.sym`
$ mkdir -p symbols/libflutter-breakpad.so/$uuid/
$ mv ./libflutter-breakpad.so.sym symbols/libflutter-breakpad.so/$uuid/
$ $CLI_BREAKPAD/breakpad/linux/$(arch)/minidump_stackwalk libflutter-breakpad.so.dmp symbols/ > libflutter-breakpad.so.log

Post a Comment for "Using Google Breakpad For Android Ndk?"