The company has recently developed an Android version of mobile game application. If you want to know the recharge situation of players since its launch, let me access the Android SDK analyzed by Huawei. Today I’m going to share with you how to add Analytics Kit to android apps. This document is based on the Android platform. For details about how to connect aN iOS application to the SDK of Huawei Analytics, see: Connecting to the iOS SDK of Huawei Analytics. The version I am accessing is 5.0.0.301.

When we start working with the SDK, we need to pay attention to two things:

  1. Refer to the latest SDK access documentation of Huawei Developer Alliance, and pay attention to the SDK version you are accessing
  2. Don’t omit code details that need to be copied from the document

Specific steps include:

  1. Configuration AppGallery Connect
  2. Integrates HMS Core SDK
  3. Access to the Analytics

1 Configure AppGallery Connect

Follow these steps to configure AppGallery Connect for your Android app. If you have both Android and iOS versions of your app, you can put both apps in the same project and then switch between them to do data analysis across platforms and devices for all users.

(1) Preparation before development

  1. Prepare package names for your Android apps (ask the developers).
  2. Log on to AppGallery Connect and create a new project.

Once the project is created, you will be taken to a page with a left navigation bar showing the various functions of the AGC menu.

(2) Open Huawei analysis services

Click “API Management” and see that the Analystics Kit is enabled by default.

Back to the left navigation bar, go to “Huawei Analytics”, you will see a variety of data reports, including user analysis, behavior analysis, audience analysis, etc. Click any menu to open analysis services. On the Project Access Settings page, set the data storage location, time zone, currency, user data retention time, and nature week, and click Finish to enable the Analytics Kit service.

Integrates HMS Core SDK

Click “Add SDK” to return to the boot page and follow the steps.

Step 1: Add the AppGallery Connect profile

A) Download configuration file “agconnect-services.json”

B) Copy the agconnect-services.json file to the application-level root directory

Step 2: Add the SDK

AppGallery Connect Gradle plugin and AppGallery Connect SDK base package in Gradle file.

A) Set project level build.gradle

allprojects {  
    repositories {  
            //Add Maven  
            maven {url 'http://developer.huawei.com/repo/'}}}... buildscript{ repositories { //Add Maven maven { url'http://developer.huawei.com/repo/' }  
    }  
    dependencies {  
        // Add this line  
        classpath 'com. Huawei. Agconnect: agcp: 1.1.1.300'}}Copy the code

B) Set build.gradle at the module level

dependencies {  
    // Add this line  
    implementation 'com. Huawei. Agconnect: agconnect - core: 1.0.0.300'}... // Add to the bottom of the file apply plugin:'com.huawei.agconnect'
Copy the code

C) Click Sync Now or Sync Project with Gradle Files to start building the Project.

Access to the Analytics

  1. Initialize the Analytics SDK in your app The last step is to add the initialization code to your app. Use the getInstance interface SDK to complete the initialization based on the configuration.

  2. The onEvent interface logs defining events. If you are not sure how to mark events, check the event description.

  3. Refer to API Description to invoke interfaces to implement various functions. In addition, you are advised to enable the debugging mode during development. You can use the application debugging function of Huawei analysis to view the reported events in real time, observe the reported results, and perform commissioning.

Enable/disable debugging mode

  1. Enable the debugging mode: Run the following command on an Android device to enable the debugging mode. After debugging mode is enabled, all events are reported in real time.
adb shell setprop debug.huawei.hms.analytics.app package_name
Copy the code
  1. To disable the debugging mode, run the following command:
adb shell setprop debug.huawei.hms.analytics.app .none.
Copy the code

After data is successfully reported, the application debugging page for Huawei analysis displays the data, as shown in the following figure:

For more details about the development guide, see the official website of Huawei Developer Alliance
Developer.huawei.com/consumer/cn…


The original link: developer.huawei.com/consumer/cn…

Original author: Small fish