Catch a Native crash using BreakPad

Project configuration

Git Clone project from Github

Github.com/AndroidAdva…

2. Download the NDK – 16Dl.google.com/android/rep…

The NDK 21 version cannot be edited successfully, whereas NDK 16 can be compiled successfully

3. Local. properties Configure the downloaded NDK path.
ndk.dir=/Users/xinwa/repo/android-ndk-r16b
Copy the code
4. Use Homebrew to install cmake
 brew install cmake
Copy the code
5. After the above steps are complete, recompile the build project and the message “Clang cannot be opened because developer cannot be verified” will be displayed. After this prompt appears, you need to go to the CLang program in the NDK directory, and then right click to open the terminal, and the prompt will disappear.

Catch Native exception

1. Clicking crash button will cause native crash
2. Generated crash dump information is stored in /sdcard/crashDump when the sdcrad permission is granted
3. Use the minidump_stackwalker tool in the engineering Tools directory to generate stack trace logs based on the Minidump file
./tools/mac/minidump_stackwalk crashDump/***.dmp -> crashLog.txt 
Copy the code
4. The generated log file is empty

If the crashlog. TXT file generated in this step is empty. Is caused by the lack of necessary dynamic library link library. So you need to compile the Bradkpad source code.

Clone github.com/google/brea… /configure && make to compile the project. The minidump_stackwalk file is stored in the SRC /processor/ directory. Using the program in this path, you can solve the problem of the lack of a dynamic link library and generate a log file with stack information

5. Open the file to obtain detailed crash logs

6. Symbol analysis

Symbols such as 0x77E in logs need to be parsed to know the corresponding code. You can use the ADDR2line provided in the NDK to perform a symbolic inverse solution process based on the address, the tool in $NDK_HOME toolchains/arm – Linux – androideabi – 4.9 / prebuilt/Darwin – x86_64 / bin/arm – Linux – androideabi – addr2line

X86_64 - Linux - android - addr2line - f - C - e/Users/xinwa shaowen Chapter01 / libcrash - lib. So 0 x77e output: Crash ()Copy the code

The rightmost parameter enters the symbol you want to parse, and the program outputs the result of the symbol