JNI exceptions are considered signals. You can set up signal handlers on sigaction , and then you can try to disable the crash stack, like libcorkscrew , to save this to disk. After that, you can call the Java method through the JNI interfaces to process the information you save.
Example:
int watched_signals[] = { SIGABRT, SIGILL, SIGSEGV, SIGINT, SIGKILL }; void sighandler_func(int sig, siginfo_t* sig_info, void* ptr) {
Suppose you used libcorkscrew in an ndk project, then you can get a failure stack:
#include <dlfcn.h>
Even if you can continue the program after processing the signal, but I highly recommend that you save the information on disk and process it in the next application launch. Because most of the time when you run the program, you will not work.
source share