All Products
Search
Document Center

Application Real-Time Monitoring Service:Integrate an Android app

Last Updated:Oct 23, 2025

Real User Monitoring (RUM) of Application Real-Time Monitoring Service (ARMS) provides comprehensive monitoring capabilities for iOS apps and Android apps. This topic describes how to integrate an Android app into RUM through Maven.

Prerequisite

Your application is running Android V8.0 or later.

Step 1: Add the app

  1. Log on to the ARMS console.

  2. In the left-side navigation pane, choose User Experience Monitoring > Application List. In the top navigation bar, select a region.

  3. On the Applications page, click Add Application.

  4. In the Create Application panel, click Android.

  5. In the Android panel, enter the app name, set other parameters as needed, and click Create.

    Note

    The name must be unique.

    Then, an address to which monitoring data is reported (ConfigAddress) and an app ID (AppID) are automatically generated for the app.

Step 2: Integrate the RUM SDK

Automatic integration through Maven (recommended)

In Android Studio, add Maven online dependencies to the build.gradle file of the project and import the RUM SDK of the latest version.

  1. Add the RUM plug-in dependency to the build.gradle file in the root directory of the project.

    buildscript {
        repositories {
            mavenLocal()
            google()
            mavenCentral()
            gradlePluginPortal()
        }
    
        dependencies {
            // Import the RUM plug-in dependency
            // Import the latest SDK version. For more information about the latest version, see the Android SDK documentation.
            classpath "com.aliyun.rum:alibabacloud-android-rum-plugin:1.0.7"
        }
    }
  2. In the build.gradle file, enable the plug-in and add the SDK dependency.

    Enable the RUM plug-in.

    apply plugin: "com.aliyun.rum"

    Add the SDK dependency.

    dependencies {
      // Import the RUM SDK.
      // Import the latest SDK version. For more information about the latest version, see the Android SDK documentation.
      implementation("com.aliyun.rum:alibabacloud-android-rum-sdk:1.0.7")
    }

Manual integration

  1. Download the installation package of the RUM SDK and decompress the package.

    The package contains the following contents:

    • libs folder: contains the required JAR packages and JNI libraries.

    • repo folder: contains the required plug-ins.

  2. Configure the project.

    1. Copy the repo and libs folders and respectively paste them to the project root directory and app Module directory.

      image

    2. Open the build.gradle (Gradle 7.0 or later) or settings.gradle (Gradle 7.0 or later) file under the project root directory, and add the following Maven configurations to the repositories block.

      build.gradle file configurations

      buildscript {
          repositories {
              maven {
                  url uri('./repo')
              }
              //...Other configurations
          }
      }
      
      allprojects {
          repositories {
              maven {
                  url uri('./repo')
              }
              //...Other configurations
          }
      }
      
      //...Other configurations

      settings.gradle file configurations

      pluginManagement {
          repositories {
              maven {
                  url uri('./repo')
              }
              //...Other configurations
          }
      }
      dependencyResolutionManagement {
          repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
          repositories {
              maven {
                  url uri('./repo')
              }
              //...Other configurations
          }
      }
      //...Other configurations
    3. In the build.gradle file under the project root directory, add the classpath configuration.

      // Add the following content without distinguishing Gradle versions.
      buildscript {
          dependencies {
              classpath "com.aliyun.rum:alibabacloud-android-rum-plugin:1.0.0"
          }
      }
      //...Other configurations
    4. Open the build.gradle file under the app Module directory and import the RUM plug-in and dependencies.

      apply plugin: "com.aliyun.rum"
      //...Other configurations
      android {
          //...Other configurations
          sourceSets {
              main {
                  jniLibs.srcDirs = ['libs']
              }
          }
          //...Other configurations
      }
      
      dependencies {
          implementation files('libs/alibabacloud-android-rum-sdk.jar')
          //...Other configurations
      }

Step 3: Grant permissions

To use the RUM SDK, grant the following permissions on the app.

<!--  Mandatory  -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!--  Optional  -->
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_BASIC_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

Step 4: Configure obfuscation

If you want to use ProGuard to obfuscate the code, add the following configurations.

-keep public class com.alibabacloud.rum.** { *; }
-dontwarn com.alibabacloud.rum.**

-optimizations !code/simplification/*,!field/*,!class/merging/*,!method/propagation/*,!class/unboxing/enum,!code/allocation/variable

Step 5: Initialize the RUM SDK

Add the following code to the onCreate function of the app:

import com.alibabacloud.rum.AlibabaCloudRum;

public class YourApplication extends Application {
  @Override
  public void onCreate() {
    super.onCreate();
    AlibabaCloudRum.withAppID("<your appid>") // Specify the app ID. 
      .withConfigAddress("<your config address>") // Specify the address. 
      .start(getApplicationContext());
  }
}

Verify the result

Start the APK. In the Logcat window, view the logs, and search for the RUM agent by keyword (AlibabaCloudRUM) or tag. If the following log entry appears, the RUM SDK has been integrated and data is being collected.

image