When you can't use the Dynatrace Android Gradle plugin due to certain technical limitations, opt for standalone manual instrumentation with OneAgent SDK for Android.
Follow the steps below to manually instrument your application using OneAgent SDK for Android.
Ensure that the Maven Central repository is declared.
Include the OneAgent library as a dependency to your project.
Start OneAgent manually.
Capture additional data via OneAgent SDK for Android.
When you use standalone manual instrumentation, nothing is done automatically. Ensure that every important part of your application is manually instrumented. Otherwise, OneAgent won't be able to monitor your application and send monitoring data to Dynatrace.
Ensure that the Maven Central repository is declared.
OneAgent for Android is hosted on Maven Central. In the Gradle settings file, verify that mavenCentral()
is added to the repositories
blocks under dependencyResolutionManagement
. Check the official Android documentation to see what the Gradle settings file should look like.
You might need to add mavenCentral()
to all repositories
blocks in the top-level build file.
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.
Use version 8.+
so that Gradle can automatically update the OneAgent library when a new minor version is available. When Dynatrace releases a new major version, manually upgrade to the new version—the new major version might contain breaking changes, so manual adjustments are usually required.
Single-module Android project
Add the OneAgent library as an implementation
dependency in your Android application module.
Multi-module Android projects with feature modules
Add the OneAgent library as an api
dependency in your base module (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.
Start OneAgent manually.
Use the Dynatrace.startup(Application, Configuration)
API method, and start OneAgent manually in the Application.onCreate
method.
If you need to start OneAgent at a later stage, use the Dynatrace.startup(Activity, Configuration)
API method. Provide an active Activity
as a parameter so that OneAgent can immediately monitor it.
To get the correct application identification keys (applicationId
and beaconUrl
), access the mobile instrumentation wizard for your application.
If your application supports Direct Boot, never call the Dynatrace.startup
API method from a Direct Boot aware component. Also, check Adjust communication with OneAgent SDK for Android to make sure that OneAgent can transmit data to Dynatrace.
Capture additional data via OneAgent SDK for Android.
For instance, you can create custom actions, report errors, tag specific users, and more.