Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:added missing page for broken link #17895

Merged
merged 4 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
title: Android agent native crash reporting
tags:
- Mobile monitoring
- New Relic Mobile Android
- Install configure
metaDescription: 'For Android apps monitored by New Relic Mobile, Android native crash, exception and ANR conditions are reported.'
freshnessValidatedDate: 2024-07-08
---

Starting with [New Relic Android agent version 6.7.0](https://docs.newrelic.com/docs/release-notes/mobile-release-notes/android-release-notes/android-670), 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](https://developer.android.com/ndk/guides) 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](/docs/mobile-monitoring/mobile-monitoring-ui/crashes/introduction-mobile-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](https://developer.android.com/topic/performance/vitals/anr) 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](/docs/mobile-monitoring/mobile-monitoring-ui/crashes/introduction-mobile-handled-exceptions/) (rather than crashes), since these are not considered fatal conditions.

<Callout variant="important">
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.
</Callout>

You can view detailed information about native crashes in New Relic Mobile's [**Crash analysis** UI](/docs/mobile-monitoring/mobile-monitoring-ui/crashes/crash-analysis-group-filter-your-crashes), or receive crash notifications by [email](/docs/mobile-monitoring/mobile-monitoring-ui/crashes/receive-crash-notifications-email). You can also explore the crash data deeper with [New Relic Insights](/docs/mobile-monitoring/mobile-monitoring-ui/crashes/crash-analysis-group-filter-your-crashes#insights), or [integrate with ticketing systems](/docs/mobile-monitoring/mobile-monitoring-ui/crashes/file-tickets-mobile-app-crashes) for further investigation.


## Configuration [#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](https://search.maven.org/search?q=g:com.newrelic.agent.android%20AND%20a:agent-ndk) and follow semantic versioning conventions. Refer to [Android agent release notes](/docs/release-notes/mobile-release-notes/android-release-notes/) for full details on releases and downloads.

## Enable native crash reporting [#startup]

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("<appToken>")
.start(this.getApplication());
```


## Disable native crash reporting [#disable-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("<appToken>")
.start(this.getApplication());
```

## Debug the native crash reporter [#debug-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](/docs/mobile-monitoring/new-relic-mobile-android/api-guides/android-agent-configuration-feature-flags#logging). 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 [#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.

6 changes: 5 additions & 1 deletion src/nav/mobile-monitoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ pages:
- title: Configure the New Relic Gradle plugin
path: /docs/mobile-monitoring/new-relic-mobile-android/install-configure/configure-new-relic-gradle-plugin
- title: Crash reporting
path: /docs/mobile-monitoring/new-relic-mobile-android/install-configure/android-agent-crash-reporting
pages:
- title: Overview of crash reporting
path: /docs/mobile-monitoring/new-relic-mobile-android/install-configure/android-agent-crash-reporting
- title: Native crash reporting
path: /docs/mobile-monitoring/new-relic-mobile-android/install-configure/android-agent-native-crash-reporting
- title: App launch time metrics
path: /docs/mobile-monitoring/new-relic-mobile-android/install-configure/configure-app-launch-time-android-apps
- title: Distributed tracing
Expand Down
Loading