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.
-
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
orapi
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.
1dependencies {2 implementation 'com.dynatrace.agent:agent-android:8.+'3}- For multi-module Android projects with 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 animplementation
dependency to these internal Android library modules.
OneAgent for Android is hosted on Maven Central. You only have to add this repository to your
build.gradle
file. Many Android projects already contain themavenCentral()
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. - For single-module Android project you should add the OneAgent library as
-
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 theDynatrace.startup
is never called from a Direct Boot aware component.1public class YourApplication extends Application {23 @Override4 public void onCreate() {5 super.onCreate();6 Dynatrace.startup(this, new DynatraceConfigurationBuilder("<YourApplicationID>", "<ProvidedBeaconUrl>")7 ... // additional configuration8 .buildConfiguration());9 }10}Go to the
Instrumentation
page of your mobile app in Dynatrace to obtain the correct values. -
Use OneAgent SDK for Android to enhance mobile user experience data
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.