xCrash is a crash reporting library for Android. It support catching native crash and Java exception.
xCrash can generate a tombstone file (similar format as Android system's tombstone file) in the directory you specified when the App process crashes. And, no root permission or any system permissions are required.
xCrash is used in a variety of Android APPs (including iQIYI Video) from iQIYI for many years.
- Support Android 4.0 - 9.0 (API level 14 - 28).
- Support armeabi, armeabi-v7a, arm64-v8a, x86 and x86_64.
- Catching native crash and Java exception.
- Setting which thread's info should be dumped via regular expressions.
- Dumping detailed memory usage statistics.
- Do not require root permission or any system permissions.
- Declaring JCenter repository in Project's
build.gradle
.
allprojects {
repositories {
jcenter()
}
}
- Declaring a dependency in Module's
build.gradle
.
dependencies {
implementation 'com.iqiyi.xcrash:xcrash-android-lib:2.0.5'
}
- Selecting one or more ABI you need in Module's
build.gradle
.
android {
defaultConfig {
ndk {
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
}
- Adding rules in
proguard-rules.pro
.
-keep class xcrash.NativeCrashHandler {
native <methods>;
void callback(...);
}
- Initialize xCrash in
Application#attachBaseContext()
.
public class MyCustomApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
xcrash.XCrash.init(this);
}
}
- That's all.
Tombstone files will be written to Context#getFilesDir() + "/tombstones"
directory by default. (usually in: /data/data/<APP_PACKAGE_NAME>/files/tombstones
)
There is a more practical and complex sample APP in the src/java/xcrash_sample
folder.
If you want to build xCrash from source code. Follow this guide:
-
Download Android NDK r16b, set environment PATH. (support for armeabi has been removed since r17)
-
Build and install the native libraries.
cd ./src/native/
./build.sh
./install.sh
- Build AAR library.
cd ./src/java/xcrash/
./gradlew :xcrash_lib:build
See xCrash Contributing Guide.
xCrash is MIT licensed, as found in the LICENSE file.
xCrash documentation is Creative Commons licensed, as found in the LICENSE-docs file.