You can use the Dynatrace Android Gradle plugin only for Android projects that use the Android Gradle plugin to build the app. You should apply the Dynatrace Android Gradle to the top-level build file (either build.gradle
or build.gradle.kts
), which is located in the root project directory. This approach allows the plugin to properly configure the Android subprojects and establish the auto-instrumentation process as part of the Android build process.
The Dynatrace Android Gradle plugin is hosted on Maven Central, and the technical documentation is available as DSL reference.
In a couple of months, we'll stop setting cookies to file scheme domains for hybrid applications. See Disable cookies for file domains for more details and action items.
Jetpack Compose auto-instrumentation is enabled by default starting with Dynatrace Android Gradle plugin version 8.271.
The Dynatrace Android Gradle plugin uses bytecode instrumentation to instrument your app. It can instrument the source files of all subprojects and third-party libraries. Performance-wise, bytecode instrumentation is quick and has a low impact on the build time. By providing support for incremental builds and the build cache, the instrumentation of apps will be almost unnoticed.
Java and Kotlin: The Dynatrace Android Gradle plugin supports the instrumentation of Java and Kotlin classes. It also supports other JVM languages.
Obfuscations and optimization: The auto-instrumentation process is completed before the R8 Gradle task. If you use another tool for obfuscation, you must ensure that the obfuscation task is executed after the auto-instrumentation process.
Security and APK-hardening tools: Bytecode instrumentation happens before obfuscation and before Android Dexer (D8) transforms the .class
bytecode into .dex
bytecode that can be executed in the Android Runtime. Therefore, the plugin can ensure maximum compatibility with other security-focused and APK-hardening tools that calculate checksums for the DEX code, such as DexGuard and Arxan.
The Android Gradle plugin only instruments the AndroidManifest.xml
and other .class
files. It doesn’t instrument the following components:
.html
and .js
files.xml
filesThere might be compatibility issues with other performance monitoring plugins, especially when these plugins instrument OneAgent for Android. We recommend either using only one performance monitoring plugin or verifying via manual testing that the plugins you've chosen are compatible.
The Dynatrace Android Gradle plugin supports Gradle build-specific capabilities, including the following:
splits
block so that the instrumentation step is executed only once.build.gradle.kts
files.excludes
property: With the excludes
property of the Android Gradle plugin, you can disable instrumentation for specific classes. This property is similar to the exclude
property of the Dynatrace Android Gradle plugin. However, when you use the Dynatrace property, our plugin still instruments some very important classes to ensure that instrumentation is always valid. With the Android excludes
property, all the specified classes aren't instrumented, which might negatively affect the instrumentation.The Android Gradle plugin provides a wide range of configuration options to customize your Android application build and the monitored mobile user experience data.
The Gradle snippet from the Instrumentation page and the Gradle snippets from the documentation contain sample names for variant-specific configuration, such as sampleConfig
. To understand this better, see how variant-specific configurations are used.
The following options can be used to customize OneAgent SDK for Android monitoring capabilities and fine-tune the auto-instrumentation process.
The plugin also provides additional configuration options to customize the instrumentation process:
The following configuration options can be used to adjust the default OneAgent configuration:
These options are especially helpful when used along with the automatic OneAgent startup. They can also be used to adjust the OneAgent configuration when approached with the manual startup, but you need to be careful because the settings can easily be overridden with ConfigurationBuilder
.
Our plugin scans all subprojects and configures the auto-instrumentation process for your application modules. Other modules are unaffected by the plugin. In this case, you might need to adjust the instrumentation process for an Android project with: