目录

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

  1. Download and decompress the ZIP packages of the HMS Base SDK and SDKs of the required kits.

    For details, please refer to Eclipse SDK Download.

  2. Import all SDK projects to your workspace.
    1. Go to File > Import > 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, and you can change as needed.

      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 projects 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. Right-click the HMSSdkAvailableUpdate project and choose Properties from the shortcut menu.
  4. Choose Android from the navigation tree. Then, click Add in the Library area, select the HMSSdkUI project, and click Apply and Close.

  5. Because the XML file in the Eclipse IDE does not support the dollar sign ($), replace ${applicationId} in the AndroidManifest.xml file of the Agconnect-core, HMSSdkAvaliableUpdate, HMSSdkDevice, and Update projects with your app package name.
    <application>
        <provider
            android:name="com.huawei.agconnect.core.provider.AGConnectInitializeProvider"
            android:authorities="${applicationId}.AGCInitializeProvider"
            android:exported="false" />
        <service
            android:name="com.huawei.agconnect.core.ServiceDiscovery"
            android:exported="false" />
    </application>

Copying the HMSSdkStats Resource Files to Your Project Directory

Copy the resource files in the assets directory of the HMSSdkStats project to the assets directory of your project.

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

Configuring the project.properties File

Open the project.properties file in your project directory, and add the following code to merge the Manifest files in the subprojects:

manifestmerger.enabled=true

The ADT version must be 17 or later.

Configuring the App ID in the AndroidManifest.xml File

  1. Open the AndroidManifest.xml file in your app project directory.

  2. Configure your app ID.

    Replace 123456789 with the app ID that you requested from HUAWEI Developers.

    <meta-data
    android:name="com.huawei.hms.client.appid"
    android:value="123456789" />

Configuring Obfuscation Scripts

Before building the APK, configure the obfuscation configuration file to prevent the HMS Core SDK from being obfuscated.

Open the obfuscation configuration file proguard-project.txt and add configurations to exclude the HMS Core SDK from obfuscation.
-ignorewarnings
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
-keep class com.huawei.hianalytics.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}