Android agent configuration and feature flags

New Relic Mobile's Android agent provides configuration settings to change the default behavior of the agent. For an explanation of Mobile custom data types, see Add custom data to New Relic Mobile.

Change configuration settings

All settings, including the call to invoke the agent, are called in the onCreate method of the MainActivity class. To change settings, call the setting in one of two ways (if the setting supports it):

  • Change the setting on its own line for each specific condition:

    NewRelic.disableFeature(FeatureFlag.DefaultInteractions);
    NewRelic.enableFeature(FeatureFlag.CrashReporting);
    NewRelic.withApplicationToken(<NEW_RELIC_TOKEN>).start(this.getApplication());
    

    OR

  • Change the setting as part of the agent start call using the .with method:

    NewRelic.withApplicationToken(<NEW_RELIC_TOKEN>)
            .withDefaultInteractions(false)
            .withCrashReporting(true)
            .start(this.getApplication());

Analytics settings

withAnalyticsEvents
FeatureFlag.AnalyticsEvents

Enable or disable collection and reporting of analytics events. These are reported to Insights and used in the Crash analysis page.

Type Boolean
Default true

Application settings

withApplicationVersion

Set custom application version strings.

Type String
Default Defaults to version number set in AndroidManifest.xml
withApplicationBuild

Set custom application build strings.

Type String
Default Defaults to build ID set in AndroidManifest.xml

Crash and error reporting settings

withCrashReportingEnabled
FeatureFlag.CrashReportingEnabled

Enable or disable crash reporting.

Type Boolean
Default true
FeatureFlag.HandledExceptions

Enable or disable recording handled exceptions events, which appear on the Handled exception page.

Type Boolean
Default true

Interaction settings

withInteractionTracing
FeatureFlag.InteractionTracing

Enable or disable interaction tracing. Trace instrumentation still occurs, but no traces are harvested. This will disable default and custom interactions.

Available for Android agent version 5.4.0 or higher.

Type Boolean
Default true
withDefaultInteractions
FeatureFlag.DefaultInteractions

Enable or disable default interactions. Trace instrumentation still occurs, but no traces are harvested. This will enable or disable default interactions only while custom interactions remain enabled.

Type Boolean
Default true

Networking settings

FeatureFlag.NetworkRequests

Enable or disable reporting successful HTTP requests to the MobileRequest event type in Insights.

Available for Android agent version 5.14.0 or higher.

Type Boolean
Default

true

Enabled by default as of agent version 5.15.2

FeatureFlag.NetworkErrorRequests

Enable or disable reporting network and Http request errors to MobileRequestError event type in Insights.

Available for Android agent version 5.11.0 or higher.

Type Boolean
Default true
withHttpResponseBodyCaptureEnabled
FeatureFlag.HttpResponseBodyCaptureEnabled

Enable or disable capture of HTTP response bodies for HTTP error traces, and MobileRequestError events.

Type Boolean
Default true

Logging settings

withLoggingEnabled

Enable or disable agent logging.

Type Boolean
Default true
withLogLevel

Specifies the log level. Options include:

  • ERROR (least verbose)
  • WARNING
  • INFO (default)
  • VERBOSE
  • DEBUG
  • AUDIT (most verbose)
Type String
Default AgentLog.INFO

To increase your logging level in the app, add .withLogLevel to your NewRelic.withApplicationToken() method call. For example:

NewRelic.withApplicationToken("YOUR_APP_TOKEN")
                    .withLogLevel(AgentLog.DEBUG)
                    .start(this.getApplication());

For more help

Recommendations for learning more: