You can use SDK for app monitoring to obtain comprehensive crash analysis results, such as Java crash, native crash, ANR, and JavaScript errors that are captured.


An app monitoring task is created for the app. For more information, see Create an app monitoring task.

Background information

This topic applies to Android Studio projects that use Gradle to manage dependencies. For more information, visit ha_android_demo.

Step 1: Add dependencies

Add Maven dependencies.

  1. Add the Alibaba Cloud Maven repository URL to the build.gradle project.
        repositories {    
        maven { url "" }
  2. Add the following code to the dependencies{ } code segment of the build.gradle project in the app module:
    compile('com.aliyun.ams:alicloud-android-ha-adapter:') {
    compile('com.aliyun.ams:alicloud-android-ha-crashreporter:1.2.1-open@aar') {

Step 2: Initialize the instance

  1. Start the crash analysis service in onCreate of the custom application class.

        public class MyApplication extends Application {
        public void onCreate() {
        private void initHa() {
           Log.e("ha", "init");
           //The preceding code is required. Otherwise, the server cannot receive data.
         AliHaConfig config = new AliHaConfig();
         config.appKey = "<yourAppKeyId>";         //appKey
           config.appVersion = "x.xx";         //The app version.
           config.appSecret = "<yourAppKeySecret>";  //appSecret
  = "<yourChannelId>";        //The custom channel ID of the app.
           config.userNick = null;
           config.application = this;
           config.context = getApplicationContext();
           config.isAliyunos = false;          // Specifies whether the app operating system is YunOS.
           AliHaAdapter.getInstance().startCrashReport(config);     // Starts CrashReport.
    Note You can obtain the key-secret pair of the app from the file downloaded in the Step4 section of the Create an app monitoring task topic.
  2. Specify the custom application in AndroidManifest.xml.

        android:theme="@style/AppTheme" >

Step 3: Update the channel ID


Step 4: Update the custom ID


Step 5: Add obfuscation rules

-keep class**{*;}
-keep class**{*;}
-keep class com.ut.device.**{*;}
-keep class com.ta.utdid2.device.**{*;}
-keep public class** { *;}
-keep public class** { *;}
-keep class**{ *;}
-keep class com.uc.crashsdk.**{*;}
-keep class com.ali.telescope.**{ *;}
-keep class**{*;}
-keep class**{*;}
-keep class dalvik.system.**{*;}
-keep class**{*;}
-keep class**{*;}
-keep class**{*;}
-dontwarn com.ali.alihadeviceevaluator.**
-dontwarn java.nio.file.**
-dontwarn org.codehaus.mojo. **


After you perform the preceding steps, you can test your app and log on to the ARMS console to view the data reports.