Standalone manual instrumentation

Version 8.x

This is documentation for the most recent version 8.x. It is only supported for AppMon 2018 October.

If you're using older version, see Android manual setup and instrumentation.

The Dynatrace Android Gradle plugin provides several configuration options to customize auto-instrumentation. If you are unable to use the plugin because of technical limitations, choose manual instrumentation. When you use manual instrumentation, nothing is done automatically and you have to ensure that every important part of your app is manually instrumented.

Include the Android Agent library as a dependency to your project.

When you use Gradle as a build automation tool, add the Android Agent library as an implementation or api dependency in one or more modules. The integration depends on the parts that you want to instrument and the project architecture that you use for your Android project. Examples:

  • For single-module Android project you should add the Android Agent library as implementation dependency in your Android application module.
dependencies {
    implementation 'com.dynatrace.agent:agent-android:8.+'
}
  • For multi-module Android projects with dynamic-feature modules, add the Android Agent library as an api dependency in your base module, the Android application module. If you use internal Android library modules that need to be instrumented, add the Android Agent library as an implementation dependency to these internal Android library modules.

Android Agent is hosted on JCenter and MavenCentral. You only have to add one of these two repositories in your build.gradle file. Most Android projects already contain the jcenter() repository and no additional modification is needed.

We recommend version 8.+ because Gradle automatically updates the plugin whenever a new version is available. When Dynatrace releases a new major version, you must manually upgrade to the new version. The new major version might contain breaking changes and some manual adjustments might be needed.

Start Android Agent.

Use the start-up method to initialize, configure, and start Android Agent as shown below. It's recommended that you start Android Agent in the onCreate method from your application class. If your app supports Direct Boot, make sure that the Dynatrace.startup is never called from a Direct Boot aware component.

public class YourApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        Dynatrace.startup(this, new AppMonConfigurationBuilder("<YourApplicationID>", "<YourAgentPathUrl>")
            ... // additional configuration
            .buildConfiguration());
    }
}

Go to the Instrumentation page of your mobile app in Dynatrace to obtain the correct values.

Use Android Agent SDK to enhance mobile user experience data

Note: If you don't manually instrument parts of your app, Android Agent won't be able to monitor your app and send captured mobile user experience data to Dynatrace.