To instrument Android Applications, you need to first build the application for the platform you are using and then add the instrumentation code.
To get started, follow the instructions below:
Build the Android Application
To build your application, follow the instructions for your platform:
Complete the following steps to configure the build for your Android application:
- Confirm the compatibility of your Gradle, Android Tools with the AppDynamics plugin versions.
- Install the Android Agent.
- Activate the plugin.
Install the Android Agent
Use the native package system to install the Android Agent. In the app module
build.gradle, add the class path of the AppDynamics Gradle Plugin to the build path dependencies clause. Use
com.appdynamics:appdynamics-gradle-plugin:20.7.1 unless you need to use another version of the AppDynamics plugin for compatibility between your Gradle and Android Tools.
If you are unable to use the Android Gradle plugin 3.4.1 or higher, you will have to use the Android Agent 20.4.0 or an earlier version.
Activate the Plugin
In your module-level
build.gradle, add the
adeum plugin immediately after the
com.android.application plugin, so that it looks similar to the example below:
Apache Maven Project
If your application is a Maven Project:
Add the following code to the
Add the following code to the
See the Knowledge Base article Use Ant to Build Android Apps with the AppDynamics Android SDK for instructions.
Instrument the Android Application
After you have completed building your application, follow the steps below:
Get Application Key
After you completed the Getting Started Wizard, you were given an EUM App Key. You will need this key when you modify the source code. In some cases, multiple mobile applications can share the same key.
If you have completed the Getting Started Wizard, but don't have your EUM App Key, see Get Your Application Key.
Add the Required Permissions
Open your application's
AndroidManifest.xml file and verify that it has these permissions:
If both of these permissions are not present, add them.
Modify the Source
In the source file that defines your application's primary Activity, add the following import:
In your primary Activity's
onCreate()method, add the following lines, passing in the EUM App Key from step 2 above:
Save the file.
Your code should look something like this.
Configure the Android Agent to report metrics and screenshots to the SaaS EUM Server and Screenshot Service in your region when initializing the agent with the methods
withScreenshotURL. (If you are using an on-premises EUM Server, see Customize the Agent Configuration for implementation details.)
Verify the Instrumentation
See Verify the Android Instrumentation for build and verification instructions.
Upgrade the Android Mobile Agent
As new features are added to the agent, you will need to upgrade the Android SDK in your app.
To upgrade, you simply update the build file for your platform:
The process of installing and updating the latest Android SDK is the same.