Starting with New Relic Android agent version 6.7.0, to help track and diagnose native crashes, reporting and analysis has been enhanced to include signal violations and other faults that occur at the native code level during runtime.
These enhancements include:
Native crash reports: The Android agent will signal violations and other crashes reported by the app during runtime, including:
- Signal 4 (Illegal instruction)
- Signal 6 (Abnormal termination)
- Signal 7 (Bus error/bad memory access)
- Signal 8 (Floating-point exception)
- Signal 11 (Segmentation violation/invalid memory reference)
Native runtime exceptions: The native agent will report any unhandled C++ exceptions thrown by the app during runtime and report them as handled exceptions. Unhandled exceptions are usually fatal and will crash the application.
Application Not Responding (ANR) conditions: The native agent will detect and report Application Not Responding conditions where an Activity or service thread has been blocked for longer than Android's allowable time, which is 5 seconds for foreground activities, and 5 to 200 seconds for services. ANR conditions will be reported as a handled exception (rather than crashes), since these are not considered fatal conditions.
重要
Native crash reporting is an incubating feature. Native crash monitoring is difficult at best, but the agent will make all best-attempts to detect and report these conditions. It may miss or incompletely report some conditions, and there may be latency viewing these conditions in the application dashboard.
Symbolication of native symbols will not be supported in early NDK agent releases. When native symbols for an app are not present, the stack trace produced by a crash consists only of these obfuscated labels, which are not easily readable.
You can view detailed information about native crashes in New Relic Mobile's Crash analysis UI, or receive crash notifications by email. You can also explore the crash data deeper with New Relic Insights, or integrate with ticketing systems for further investigation.
Configuration
Configuration requires adding an additional dependency in the build.gradle
file of the app project(s) that start the new Relic agent:
dependencies { implementation 'com.newrelic.agent.android:agent-ndk:1.+'}
Android agent artifacts can be found on MavenCentral and follow semantic versioning conventions. Refer to Android agent release notes for full details on releases and downloads.
Enable native crash reporting
In your app's code where the New Relic agent is added (usually in MainActivity
), enable the NativeReporting
feature flag prior to starting the agent:
NewRelic.enableFeature(FeatureFlag.NativeReporting);NewRelic .withApplicationToken("APP_TOKEN") .start(this.getApplication());
Disable native crash reporting
If you want to use another native crash reporting tool, disable native crash reporting by calling NewRelic.disableFeature(FeatureFlag/NativeReporting)
prior to agent initialization. For example:
NewRelic.disableFeature(FeatureFlag.NativeReporting);NewRelic .withApplicationToken("APP_TOKEN") .start(this.getApplication());
Debug the native crash reporter
Crash reporting for Android is designed to work with other crash reporting frameworks by chaining the uncaught exception handler if it is already registered.
Any problems that arise during reporting will appear in logcat. Each time New Relic traps a violation, it is logged to DEBUG
level. For example, for a segment violation you'd see the following log:
Signal 11 intercepted: Segmentation violation (invalid memory reference)Invoking previous handler for signal 11
Native report delivery is deferred until the next app invocation, so you not see crash reports in the New Relic Mobile user interface until the app has been launched again. In the event of a crash, the native agent will generally not have enough time or stability to process the report. Instead, the report data is quickly written to local storage, to be processed the next time the app is launched.
Troubleshooting
Native reports are stored on device as JSON files in /data/data/APP_PACKAGE_NAME/cache/newrelic/reports
. This directory should not contain any reports after the app launch following a crash.
As with other agent runtime information, the native agent writes its status to logcat to blend in with agent runtime status. The agent’s log tag is com.newrelic.android
and can be isolated from other runtime logging by running adb logcat | grep "com.newrelic.android"
from the shell.