README.ANDROID 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. Google Breakpad for Android
  2. ===========================
  3. This document explains how to use the Google Breakpad client library
  4. on Android, and later generate valid stack traces from the minidumps
  5. it generates.
  6. This release supports ARM, x86 and MIPS based Android systems.
  7. This release requires NDK release r11c or higher.
  8. I. Building the client library:
  9. ===============================
  10. The Android client is built as a static library that you can
  11. link into your own Android native code. There are two ways to
  12. build it:
  13. I.1. Building with ndk-build:
  14. -----------------------------
  15. If you're using the ndk-build build system, you can follow
  16. these simple steps:
  17. 1/ Include android/google_breakpad/Android.mk from your own
  18. project's Android.mk
  19. This can be done either directly, or using ndk-build's
  20. import-module feature.
  21. 2/ Link the library to one of your modules by using:
  22. LOCAL_STATIC_LIBRARIES += breakpad_client
  23. NOTE: The client library requires a C++ STL implementation,
  24. which you can select with APP_STL in your Application.mk
  25. It has been tested succesfully with both STLport and GNU libstdc++
  26. I.2. Building with a standalone Android toolchain:
  27. --------------------------------------------------
  28. All you need to do is configure your build with the right 'host'
  29. value, and disable the processor and tools, as in:
  30. $GOOGLE_BREAKPAD_PATH/configure --host=arm-linux-androideabi \
  31. --disable-processor \
  32. --disable-tools
  33. make -j4
  34. The library will be under src/client/linux/libbreakpad_client.a
  35. You can also use 'make check' to run the test suite on a connected
  36. Android device. This requires the Android 'adb' tool to be in your
  37. path.
  38. II. Using the client library in Android:
  39. ========================================
  40. The usage instructions are very similar to the Linux ones that are
  41. found at https://chromium.googlesource.com/breakpad/breakpad/+/master/docs/linux_starter_guide.md
  42. 1/ You need to include "client/linux/handler/exception_handler.h" from a C++
  43. source file.
  44. 2/ If you're not using ndk-build, you also need to:
  45. - add the following to your compiler include search paths:
  46. $GOOGLE_BREAKPAD_PATH/src
  47. $GOOGLE_BREAKPAD_PATH/src/common/android/include
  48. - add -llog to your linker flags
  49. Note that ndk-build does that for your automatically.
  50. 3/ Keep in mind that there is no /tmp directory on Android.
  51. If you use the library from a regular Android applications, specify a
  52. path under your app-specific storage directory. An alternative is to
  53. store them on the SDCard, but this requires a specific permission.
  54. For a concrete example, see the sample test application under
  55. android/sample_app. See its README for more information.
  56. III. Getting a stack trace on the host:
  57. =======================================
  58. This process is similar to other platforms, but here's a quick example:
  59. 1/ Retrieve the minidumps on your development machine.
  60. 2/ Dump the symbols for your native libraries with the 'dump_syms' tool.
  61. This first requires building the host version of Google Breakpad, then
  62. calling:
  63. dump_syms $PROJECT_PATH/obj/local/$ABI/libfoo.so > libfoo.so.sym
  64. 3/ Create the symbol directory hierarchy.
  65. The first line of the generated libfoo.so.sym will have a "MODULE"
  66. entry that carries a hexadecimal version number, e.g.:
  67. MODULE Linux arm D51B4A5504974FA6ECC1869CAEE3603B0 test_google_breakpad
  68. Note: The second field could be either 'Linux' or 'Android'.
  69. Extract the version number, and a 'symbol' directory, for example:
  70. $PROJECT_PATH/symbols/libfoo.so/$VERSION/
  71. Copy/Move your libfoo.sym file there.
  72. 4/ Invoke minidump_stackwalk to create the stack trace:
  73. minidump_stackwalk $MINIDUMP_FILE $PROJECT_PATH/symbols
  74. Note that various helper scripts can be found on the web to automate these
  75. steps.
  76. IV. Verifying the Android build library:
  77. ========================================
  78. If you modify Google Breakpad and want to check that it still works correctly
  79. on Android, please run the android/run-checks.sh script which will do all
  80. necessary verifications for you. This includes:
  81. - Rebuilding the full host binaries.
  82. - Rebuilding the full Android binaries with configure/make.
  83. - Rebuilding the client library unit tests, and running them on a device.
  84. - Rebuilding the client library with ndk-build.
  85. - Building, installing and running a test crasher program on a device.
  86. - Extracting the corresponding minidump, dumping the test program symbols
  87. and generating a stack trace.
  88. - Checking the generated stack trace for valid source locations.
  89. For more details, please run:
  90. android/run-checks.sh --help-all