Downloading the SDK
- Download the Analytics SDK and Eclipse project packages that it depends on. Then decompress the packages. For details, please refer to Eclipse SDK Download.
- Both the analyticssdk-eclipse-{version} and hmssdk-eclipse-{version} packages contain the Agconnect-core folder. Use the Agconnect-core folder in the analyticssdk-eclipse-{version} package.
- Both the opendevicesdk-eclipse-{version} and hmssdk-eclipse-{version} packages contain the Security-encrypt and Security-ssl folders. Use the Security-encrypt and Security-ssl folders in the hmssdk-eclipse-{version} package.
- Download the third-party open-source JAR packages that Analytics Kit indirectly depends on from official websites. The following table describes the packages.
Software | Version | Description |
OkHttp | 3.11.0 | Third-party open-source JAR package on which Analytics Kit indirectly depends, mandatory. |
Okio | 1.14.0 | JAR package on which OkHttp 3.11.0 depends, mandatory. |
greenDAO | 3.3.0 | Third-party open-source JAR package on which Analytics Kit depends, mandatory. |
greenDAO API | 3.3.0 | JAR package on which greenDAO 3.3.0 depends, mandatory. |
- Go to to import all SDK projects to your workspace.
- Go to and click Next.

- Click Browse and select the directory where the project is located. The projects to be imported are displayed under Projects. By default, all projects are selected. Click Finish.
- The projects to be imported must be located in the same drive as your 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.
- The Datastore-annotation directory extracted from the analyticssdk-eclipse-{version} package provides JAR packages instead of SDK subprojects. The JAR packages do not need to be imported.
- As the XML file in Eclipse does not support the dollar sign ($), replace ${ApplicationId} in the AndroidManifest.xml files of the Agconnect-core, HMSSdkAvailableUpdate, HMSSdkOpendevice, HMSSdkAnalytics, HMSSdkDevice, and Update subprojects with your app package name. After that, press Ctrl+S to save the modification in all files.
- Add JAR packages.
- Right-click your project and go to .
- Go to Java Build Path > Libraries > Add External JARs from the navigation tree.

- Add okhttp-3.11.0.jar, okio-1.14.0.jar, greendao-3.3.0.jar, greendao-api-3.3.0.jar, and the five JAR packages in the Dependencies-jar folder of the decompressed analyticssdk-eclipse-{version} package. Then, click Apply.

- Click Order and Export, select the nine JAR packages marked in the red box, and click Apply and Close.

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

- Right-click the HMSSdkAvailableUpdate project and choose Properties from the shortcut menu.
- Choose Android from the navigation tree. Then, click Add in the Library area, select the HMSSdkUI project, and click Apply and Close.

Copying Resource Files to Your Project Directory
Eclipse cannot automatically merge the assets directories. You need to manually copy files in the assets directories of the subprojects to the assets directory of your project. The resource files to be copied are as follows.
Subproject | Resource File |
HMSSdkOpendevice | grs_sdk_global_route_config_opendevicesdk.json |
HMSSdkStats | grs_sdk_global_route_config_opensdkService.json |
Security-ssl | hmsrootcas.bks and hmsincas.bks |
Network-grs | grs_sdk_server_config.json and grs_sp.bks |
Update | updatesdkcas.bks, grs_sdk_global_route_config_updatesdk.json, and grs_sdk_global_route_config_apptouchupdatesdk.json |
If duplicate resource files exist, overwrite them.
Modifying the Project Configuration
- Find and open the project.properties file in your project directory and add the following code to merge the AndroidManifest.xml files in the subprojects:
manifestmerger.enabled=true
The ADT version must be 17 or later.
- The service elements in the AndroidManifest.xml files of the Agconnect-core and Agconnect-credential subprojects cannot be automatically merged. To avoid duplication, delete the following code from the AndroidManifest.xml file of the Agconnect-core subproject:
<service
android:name="com.huawei.agconnect.core.ServiceDiscovery"
android:exported="false" />
Adding the AppGallery Connect Configuration File
- Sign in to AppGallery Connect and click My projects.
- Click the app to be configured.
- Go to .

- Eclipse does not support the AppGallery Connect plugin. Place the agconnect-services.json file in the assets directory of your project and add the following code to the Application subclass of the project. If the project does not have an Application subclass, create a subclass that extends the Application subclass, for example, MyApplication.
public class MyApplication extends Application{
// TODO: Add the following code:
@Override
public void onCreate() {
super.onCreate();
try {
AGConnectOptionsBuilder builder = new AGConnectOptionsBuilder();
builder.setInputStream(getAssets().open("agconnect-services.json"));
AGConnectInstance.initialize(this, builder);
} catch (IOException e) {
// Log exceptions.
}
}
} After that, import the following classes:
import java.io.IOException;
import java.io.InputStream;
import com.huawei.agconnect.config.AGConnectServicesConfig;
import com.huawei.agconnect.config.LazyInputStream;
import android.app.Application;
import android.content.Context;
import android.util.Log;
- Open the AndroidManifest.xml file of your project and add the Application subclass name to application. If the subclass name has been added, skip this step. In the following example, the added subclass is named MyApplication.
<application
android:name=".MyApplication"
...
>
</application> - On the Eclipse IDE menu bar, click Project and then Clean.
Configuring Obfuscation Scripts
Before building the APK, configure the obfuscation configuration file to prevent the Analytics SDK from being obfuscated.
The obfuscation configuration file is named
proguard-project.txt in Eclipse.
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}
-keep class com.huawei.agconnect.**{*;}
-keep interface com.huawei.hms.analytics.type.**{*;}