The SDK supports automatic capture of Java/Kotlin crashes, NDK native crashes, and ANR (Application Not Responding), while also providing manual error reporting and symbolicated stack trace features.
Error Types
Android RUM can monitor the following types of errors:Java/Kotlin Crashes
The SDK automatically captures unhandled Java/Kotlin exceptions, including:- Runtime exceptions (e.g.,
NullPointerException,IndexOutOfBoundsException) - Uncaught exceptions
- Application crashes
NDK Crashes (Native Crash)
If your application uses native code (C/C++), the SDK supports capturing NDK crashes and including them in error tracking.ANR (Application Not Responding)
The SDK can detect and report ANR issues, helping you identify user experience problems caused by main thread blocking.Custom Errors
In addition to automatically captured exceptions, you can use the RUM SDK to manually report custom errors for tracking business logic errors and other specific issues.Configure Crash Reporting
Basic Configuration
Crash reporting is enabled by default. After completing basic SDK integration following the SDK Integration Guide, the SDK will automatically capture unhandled exceptions in your application.
Add NDK Crash Reporting
If your application contains native code (C/C++), you need to add the NDK crash reporting module to capture native crashes.Add Dependency
Add the NDK crash reporting dependency in your app module’s
build.gradle file:build.gradle
Add ANR Reporting
ANR (Application Not Responding) occurs when the application’s main thread is blocked for more than a certain time, causing the application to become unresponsive to user input.Enable ANR Detection
Enable ANR detection in the RUM configuration:Manual Error Reporting
Using theaddError API, you can manually report handled exceptions, custom errors, or other errors not automatically captured.
Error Reporting Example
Error Source Types
RumErrorSource options:
| Value | Description |
|---|---|
RumErrorSource.NETWORK | Network error |
RumErrorSource.SOURCE | Source error |
RumErrorSource.CONSOLE | Console error |
RumErrorSource.LOGGER | Logger error |
RumErrorSource.AGENT | Agent error |
RumErrorSource.WEBVIEW | WebView error |
RumErrorSource.CUSTOM | Custom error |
Network Error Reporting Example
Get Deobfuscated Stack Traces
If your application has code obfuscation enabled (ProGuard/R8), reported crash stacks will be obfuscated. By uploading mapping files, you can restore obfuscated stacks to original class names, method names, and line numbers.Configure Gradle Plugin
Add Plugin Dependency
Add the Flashcat Gradle plugin in your project root
build.gradle file:build.gradle
Upload Mapping Files
After configuration, the plugin will automatically upload mapping files during the build process. You can also manually run the upload task:release variant:
Upload NDK Symbol Files
If you’re using NDK crash reporting, you also need to upload NDK symbol files to get readable native stacks:Plugin Configuration Options
| Property | Description |
|---|---|
versionName | App version name (defaults to version declared in android block) |
serviceName | Service name (defaults to app package name) |
site | Data reporting site |
checkProjectDependencies | Controls whether the plugin checks Flashcat SDK dependencies. Options: none (ignore), warn, fail (default) |
Mapping File Size Limits
Mapping file size is limited to 500 MB. If the file is too large, you can use the following options to reduce file size:build.gradle
Track Background Events
By default, only crashes that occur when a view is active are tracked. If you want to track crashes that occur when the app is in the background, enable background event tracking:Limitations and Considerations
Crash Detection Limitations
- SDK Initialization Timing: Crashes can only be detected after SDK initialization. It’s recommended to initialize the SDK as early as possible in
Application.onCreate(). - View Association: Crashes must be associated with a RUM view. Crashes that occur before a view is displayed or after the app is backgrounded may not be reported. This can be mitigated with
trackBackgroundEvents(true). - Sampling Rate Impact: Only crashes in sampled sessions are retained. If the session sampling rate is not 100%, some crashes may not be reported.
Symbolication Limitations
- Ensure mapping files are correctly uploaded with each new version release.
- Different build variants (e.g., debug/release) require separate mapping file uploads.
- NDK symbol files must contain debug information for proper symbolication.
Testing and Verification
Verify Java/Kotlin Crashes
- Add test code to trigger a crash in your app:
- Run the app and trigger the crash
- Restart the app and wait for the SDK to upload the crash report
- View the crash report in the Flashcat console’s Error Tracking module
Verify NDK Crashes
- Add a test crash in native code:
- Call this native method from Java/Kotlin code
- Restart the app and wait for the SDK to upload the crash report
- Confirm the stack is properly symbolicated (showing function names, file names, and line numbers)
Verify ANR
- Execute a time-consuming operation on the main thread:
- Trigger this operation and try to interact with the app
- Check if the Flashcat console received the ANR report
Error Data Structure
Each error record contains the following attributes:| Attribute | Type | Description |
|---|---|---|
error.source | string | Error source (e.g., source, network, custom) |
error.type | string | Error type or code (e.g., NullPointerException) |
error.message | string | Error message |
error.stack | string | Error stack trace |
error.is_crash | boolean | Whether it’s a crash |
context | Object | Custom context information passed via addError’s attributes |
Best Practices
-
Initialize SDK Early: Initialize the SDK in
Application.onCreate()to capture as many crashes as possible. -
Enable Background Event Tracking: If your app has significant background operations, consider enabling
trackBackgroundEvents. -
Properly Upload Symbol Files:
- Upload corresponding mapping files for each release version
- If using NDK, also upload NDK symbol files
- Integrate symbol file upload into your CI/CD pipeline
- Enrich Error Context: When manually reporting errors, attach business-related context information (e.g., user ID, operation type).
-
Filter Irrelevant Errors: Use
setErrorEventMapperto filter third-party SDK or irrelevant errors to reduce noise.