How do I manually instrument my Android app?

To manually instrument your Android app

Include the OneAgent library as dependency to your project. OneAgent for Android is hosted on JCenter and MavenCentral.

dependencies {
  implementation 'com.dynatrace.agent:agent-android:+'

Now Gradle automatically ensures that the OneAgent library is added to your project, the permissions are updated and the OneAgent library is excluded from obfuscation and optimization.

If the compileSdkVersion setting in your build.gradle file is 23 (Android 6.0) or later, then you must add the compile-time dependency for the Apache HTTP client library as shown below.

android {
    useLibrary 'org.apache.http.legacy'

Use the startup method to initialize, configure and start OneAgent as shown below. It's recommended that you start OneAgent in the onCreate method from your application class.

public class YourApplication extends Application {

    public void onCreate() {
        Dynatrace.startup(this, new DynatraceConfigurationBuilder("<YourApplicationID>", "<YourEnvironmentID>", "<ProvidedClusterUrl>")
            ... // additional configuration

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

Use OneAgent SDK for Mobile to enrich mobile user experience data


  • OneAgent doesn't contain a specific web request tagging and timing API for 3rd-party web request frameworks. You have to use the general API methods (for example, Dynatrace.getWebRequestTiming(String)).
  • There is limited support for multi-process applications, as each process starts its own OneAgent and has its own session number.