AppDynamics switched from Semantic Versioning to Calendar Versioning starting in February 2020 for some agents and March 2020 for the entire product suite.


    Skip to end of metadata
    Go to start of metadata

    Related pages:

    Your Rating:
    Results:
    1 Star2 Star3 Star4 Star5 Star
    31 rates

    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:

    1. Build the Android Application
    2. Instrument the Android Application 

    Build the Android Application

    To build your application, follow the instructions for your platform:

    If you are fetching the AppDynamics Android SDK from the AppDynamics Download page, see Download Manually.

    Gradle/Android Studio

    Complete the following steps to configure the build for your Android application:

    1. Confirm the compatibility of your Gradle, Android Tools with the AppDynamics plugin versions.
    2. Install the Android Agent.
    3. 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.5.0 unless you need to use another version of the AppDynamics plugin for compatibility between your Gradle and Android Tools

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.1.0'
            classpath 'com.android.tools.build:gradle:3.4.1' // 3.4.1 or higher
            classpath 'com.appdynamics:appdynamics-gradle-plugin:20.5.0' // this line added for AppDynamics
        }
    }
    allprojects {
        repositories {
            jcenter()
        }
    }

    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:


    apply plugin: 'com.android.application'
    apply plugin: 'adeum' // this line added for AppDynamics

    Apache Maven Project

    If your application is a Maven Project:

    1. Add the following code to the <dependencies> section:

      <dependency>
         <groupId>com.appdynamics</groupId>
         <artifactId>appdynamics-runtime</artifactId>
         <version>1.0</version>
      </dependency>
    2. Add the following code to the <plugins> section:

      <plugin>
          <groupId>com.appdynamics</groupId>
          <artifactId>appdynamics-maven-plugin</artifactId>
          <version>1.0</version>
          <executions>
              <execution>
                  <phase>compile</phase>
                  <goals>
                      <goal>adinject</goal>
                  </goals>
              </execution>
          </executions>
      </plugin>

    Ant/Eclipse

    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:

    1. Get the Application Key
    2. Add the Required Permissions
    3. Modify the Source
    4. Run the Build

    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:

    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>

    If both of these permissions are not present, add them.

    Modify the Source

    1. In the source file that defines your application's primary Activity, add the following import:

      import com.appdynamics.eumagent.runtime.Instrumentation;
    2. In your primary Activity's onCreate() method, add the following lines, passing in the EUM App Key from step 2 above: 

      Instrumentation.start(<EUM_APP_KEY>, getApplicationContext());
    3. Save the file. 
      Your code should look something like this.

      import com.appdynamics.eumagent.runtime.Instrumentation;
      ...
      @Override public void onCreate(Bundle savedInstanceState) {
        Instrumentation.start(<EUM_APP_KEY>, getApplicationContext());
        ...
      }
    4. 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 withCollectorURL and withScreenshotURL. (If you are using an on-premises EUM Server, see Configure the iOS Agent for On-Prem Deployments (Optional) for implementation details.)

      import com.appdynamics.eumagent.runtime.Instrumentation;
      ...
      @Override public void onCreate(Bundle savedInstanceState) {
        Instrumentation.start(AgentConfiguration.builder()
          .withAppKey("<EUM_APP_KEY>")
          .withContext(getApplicationContext())
          // The default SaaS EUM Server and Screenshot Service are in the Americas, 
          // so you can omit the following settings if you are in the Americas.
          .withCollectorURL("https://col.eum-appdynamics.com")
          .withScreenshotURL("https://image.eum-appdynamics.com/")
          .build());
        ...
      }
      import com.appdynamics.eumagent.runtime.Instrumentation;
      ...
      @Override public void onCreate(Bundle savedInstanceState) {
        Instrumentation.start(AgentConfiguration.builder()
          .withAppKey("<EUM_APP_KEY>")
          .withContext(getApplicationContext())
          // Configure the iOS Agent to report the metrics and screenshots to 
          // the SaaS EUM Server in EMEA.
          .withCollectorURL("https://fra-col.eum-appdynamics.com")
          .withScreenshotURL("https://fra-image.eum-appdynamics.com/")
          .build());
        ...
      }
      import com.appdynamics.eumagent.runtime.Instrumentation;
      ...
      @Override public void onCreate(Bundle savedInstanceState) {
        Instrumentation.start(AgentConfiguration.builder()
          .withAppKey("<EUM_APP_KEY>")
          .withContext(getApplicationContext())
          // Configure the iOS Agent to report the metrics and screenshots to 
          // the SaaS EUM Server in APAC.
          .withCollectorURL("https://syd-col.eum-appdynamics.com")
          .withScreenshotURL("https://syd-image.eum-appdynamics.com/")
          .build());
        ...
      }

    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.

    3 Comments

    1. repositories { jcenter() }
      Remove this repositories block from here, and remove the allProjects block below.
    2. classpath 'com.android.tools.build:gradle:1.1.0'
      remove the com.android.tools line
    3. 1.0
      Use 4.5.+ for the maven pom stuff