You can use SDK for app monitoring to obtain comprehensive remote logs.


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.

Note Logs can be stored on mobile clients for a maximum of seven days.

Step 1: Add 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-tlog:') {

Step 2: Integrate the service

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

    public class MyApplication extends Application {
        public void onCreate() {
        private void initHa() {
             Log.e("ha", "init");
             AliHaConfig config = new AliHaConfig();
             config.appKey = "xxxxxxxx";
             config.appVersion = "x.xx";         //The app version.
             config.appSecret = "xxxxxxxxxxxx";  //appsecret
    = "mqc_test";        //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.
             config.rsaPublicKey = "xxxxxxx";    //The public key of TLog. This parameter is required. The appmonitor.tlog.rsaSecret field in the aliyun-emas-services.json file downloaded from the Enterprise Mobile Application Studio (EMAS) console indicates the public key information. To download the file, go to the EMAS console, click App Management in the left-side navigation pane, and then find the desired app. In the upper-right corner, click Configuration Download.
    Note You can obtain the key-secret pair of the app from the file downloaded in the Step 4 section of the Create an app monitoring task topic.
  2. Specify the custom application in AndroidManifest.xml.

        android:theme="@style/AppTheme" >
  3. Add the following code to the defaultConfig node of build.gradle in the app module to configure Application Binary Interface (ABI):
    ndk {
            abiFilters 'armeabi-v7a'

Step 3: Obtain the remote logs

  1. Import the header file for the workflow to trigger the log information to be exported.
  2. Add code to the appropriate location to export the log information. Sample code:
    String TAG = "xxx";
    String MODEL = "xxxxx";
    TLogService.logv(MODEL,TAG,"test tlog1");
    TLogService.logd(MODEL,TAG,"test tlog2");
    TLogService.logi(MODEL,TAG,"test tlog3");
    TLogService.logw(MODEL,TAG,"test tlog4");
    TLogService.loge(MODEL,TAG,"test tlog5");


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