• Home
  • Platform modules
  • Digital Experience
  • Mobile applications
  • Android
  • SDK
  • Standalone manual instrumentation using OneAgent SDK for Android

Standalone manual instrumentation using OneAgent SDK for Android

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 standalone manual instrumentation. When you use standalone manual instrumentation, nothing is done automatically and you have to ensure that every important part of your app is manually instrumented.

  1. Include the OneAgent library as a dependency to your project.

    When you use Gradle as a build automation tool, add the OneAgent 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 OneAgent library as implementation dependency in your Android application module.
    gradle
    dependencies { implementation 'com.dynatrace.agent:agent-android:8.+' }
    gradle
    dependencies { implementation("com.dynatrace.agent:agent-android:8.+") }
    • For multi-module Android projects with dynamic-feature modules, add the OneAgent 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 OneAgent library as an implementation dependency to these internal Android library modules.

    OneAgent for Android is hosted on MavenCentral. You only have to add this repository to your build.gradle file. Many Android projects already contain the mavenCentral() 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.

  2. Start OneAgent.

    Use the start-up 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. If your app supports Direct Boot, make sure that the Dynatrace.startup is never called from a Direct Boot aware component.

    java
    public class YourApplication extends Application { @Override public void onCreate() { super.onCreate(); Dynatrace.startup(this, new DynatraceConfigurationBuilder("<YourApplicationID>", "<ProvidedBeaconUrl>") ... // additional configuration .buildConfiguration()); } }
    kotlin
    class YourApplication : Application() { override fun onCreate() { super.onCreate() Dynatrace.startup(this, DynatraceConfigurationBuilder("<YourApplicationID>", "<ProvidedBeaconUrl>") ... // additional configuration .buildConfiguration()) } }

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

  3. Use OneAgent SDK for Android to enhance mobile user experience data

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