目录

Integrating the HMS Core SDK into Your Eclipse Project

If you are using Eclipse, you can download the HMS Core SDK and integrate it into your Eclipse project.

Downloading the SDK

If you integrate the DTM SDK using Eclipse, data cannot be reported to the Firebase and Adjust platforms.

  1. Integrate the Analytics SDK before you integrate the DTM SDK. For details about how to integrate the Analytics SDK, please refer to Integrating the HMS Core SDK into Your Eclipse Project.
  2. Download and decompress the ZIP packages of the HMS Base SDK and the desired service SDK.

    For details, please refer to HMS Base Eclipse SDK Download.

  3. Go to File > Import to import all SDK projects to your workspace.
    1. Go to Android > Existing Android Code Into Workspace and click Next.

    2. Click Browse and navigate to the directory where your projects are located. Select the desired projects under Projects and click Finish. By default, all projects are selected. You can change the settings as needed.

    The projects to be imported must be located in the same drive as the workspace, for example, D:\. If they are not in the same drive, select Copy projects into workspace to copy the project files to the workspace.

Adding Project Dependencies

  1. Right-click your app project and choose Properties from the shortcut menu.
  2. Choose Android from the navigation tree. Then, click Add in the Library area, select the imported projects, and click Apply and Close.

  3. As the XML file in the Eclipse IDE does not support the dollar sign ($), replace ${applicationId} in the AndroidManifest.xml file of the dtm-api project with your app package name. DTM has restrictions on special characters in the app package name. For details, please refer to FAQs.

Copying the Resource File of the DTM SDK to Your App Project Directory

Copy the resource file in the assets directory of the dtm-core project to the assets directory of your app project.

If any other kits are involved, also copy their resource files to your project directory.

Configuring Obfuscation Scripts

If your project configuration meets all of the following conditions, you do not need to configure the obfuscation configuration file:

  1. The integrated DTM SDK version is 5.0.4.300 or later.
  2. In the project-level build.gradle file, the Android Studio gradle plugin version is 3.4.0 or later, for example, classpath 'com.android.tools.build:gradle:3.4.0'.
  3. In Gradle plugin versions earlier than 5.0, the R8 code obfuscation is not disabled, or android.enableR8=true is configured in the gradle.properties file in your project. Ignore this configuration if you use Gradle plugin 5.0 or later.

Before building the APK, configure the obfuscation configuration file to prevent Analytics Kit and DTM from being obfuscated.

Open the obfuscation configuration file proguard-project.txt in the app directory of your project and add configurations to exclude Analytics Kit and DTM from obfuscation.
-dontwarn com.huawei.hms.**
-keep interface com.huawei.hms.analytics.type.HAEventType{*;}
-keep interface com.huawei.hms.analytics.type.HAParamType{*;}
-keep class com.huawei.hms.analytics.HiAnalyticsTools{
   public static void enableLog();
   public static void enableLog(int);
}
-keep class com.huawei.hms.analytics.HiAnalyticsInstance{*;}
-keep class com.huawei.hms.analytics.HiAnalytics{*;}
-keep class com.huawei.hms.feature.** {
   public *;
}
-keep public class com.huawei.hms.common.** {
   public *;
}
-keep class com.huawei.hms.analytics.internal.filter.EventFilter{
   public void logFilteredEvent(java.lang.String, android.os.Bundle);
   public java.lang.String getUserProfile(java.lang.String);
}
-keep public class com.huawei.hms.dtm.EventFilter {
   public <fields>;
   public <methods>;
}