Dynatrace auto-instrumentation for Android

To set up user experience monitoring for your Android app, use Dynatrace auto-instrumentation. Auto-instrumentation automatically adds OneAgent to your app and instruments your app without modifying its source code.

Because auto-instrumentation modifies the Dalvik byte-code of your mobile app after you generate the APK file, you have to ensure that your instrumented app is signed with your Google Play certificate before you upload the instrumented APK to the Google Play store.

In case auto-instrumentation doesn't fit your requirements, you can use manual instrumentation to fully customize instrumentation. Manual instrumentation is done on a source code level and you can only instrument your own source code. It isn't therefore possible to instrument 3rd party libraries.

Requirements

  • Supported OS versions. See Android Studio system requirements.

  • JAVA_HOME environment variable must point to a JDK 1.8

  • Install ia32-libs on 64-bit Linux.

How to use auto-instrumentation

The easiest and fastest way to use auto-instrumentation is via the Dynatrace Gradle plugin. The Dynatrace Gradle plugin automatically triggers auto-instrumentation on every build. Because auto-instrumentation inserts OneAgent start-up at the beginning of the application start procedure, you can't control the start-up sequence using OneAgent SDK calls. OneAgent ignores multiple start-up calls.

If you can't use the Dynatrace Gradle plugin because you don't build your app using the Android Gradle plugin, or the Dynatrace Gradle plugin is incompatible with your build script, then you can run the auto-instrumentation script from the command line.

Limitations

  • Auto-instrumentation has to add OneAgent code into the primary .dex file. There are some limitations for multi-dex applications.
  • Auto-instrumentation only monitors the native part of a hybrid application.
  • Avoid using special characters and spaces in file and path names (for example, ( ) [ ] $ % *).  If you're having trouble instrumenting your app, rename your file to use only alphanumeric characters (a-z, A-Z, 0-9) and the dot character (.) and try again.
  • APK protection tools (for example, DexGuard) aren't fully supported, this includes features like byte-code protection and tamper detection.
  • You can't auto-instrument apps using minSDK 24 or higher, because dex files format change has been introduced. If you don't use the new language features, and downgrade to the Android Gradle plugin 2.3.3, it is still possible to generate an APK file in the old format and use auto-instrumentation.
  • You can't instrument Android App Bundles
  • The agent does not support Direct Boot mode. You have to manually startup the agent (see DTXAutoStart property) once the device is unlocked.