• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

How to download and Integrate the HUAWEI Account Kit SDK [Eclipse IDE]

Search This thread

XDARoni

XDA Community Manager
1. Eclipse SDK Download
If you are using the Eclipse IDE, download the HMS SDK package and integrate it locally.

Integrating the HMS SDK into Your App Project in the Eclipse IDE
Before starting your development in the Eclipse Integrated Development Environment (IDE), download the HMS SDK and integrate it into your app project.

Downloading the SDK
1. Download and decompress the zip packages of the HMS Base SDK and HUAWEI Account SDK.
For details, please refer to Eclipse SDK Download.
2. Import all SDK projects to your workspace.

a. Go to File > Import > Android > Existing Android Code Into Workspace and click Next.
4pviyZG.png

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

NOTE: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 file to the workspace.
E3r5y6i.png


Adding Project Dependencies
1. Right-click your app project and choose Properties from the shortcut menu.
2. Choose Android from the navigation tree, click Add, select the imported projects, and click OK.
QfSiGAj.png

3. As the XML file in the Eclipse IDE does not support the dollar sign ($), replace ${applicationId} in the AndroidManifest.xml file of the HMSSdkBase and Agconnect-core projects with your app package name
Code:
<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 HMSSdkBase Properties Files to Your App Project Directory
Copy the properties files in the assets directory of the HMSSdkBase project to the assets directory of your app project.

NOTE: If any other kits are involved, copy the properties files of these kits to your app project directory.
wGAUapE.png

Configuring the project.properties File
Find and open the file in your project directory and add the following code to merge the manifest files in the subprojects:
Code:
manifestmerger.enabled=true
Adding the AppGallery Connect Configuration File
1. Sign in to AppGallery Connect and select My apps.
2. Find your app from the list and click the app name.
IiBd6XA.png

3. Go to Develop > Overview > App information.
4. Click agconnect-services.json to download the configuration file.
aOnXYax.png

5. The Eclipse IDE does not support the AppGallery Connect plug-in. Therefore, you need to 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, you need to create a subclass that is inherited from the Application subclass. For example, create a MyApplication class.
Code:
public class MyApplication extends Application{
    @Override
    public void onCreate() {
        super.onCreate();
    }
    // TODO: Add the following code:
    @Override
    protected void attachBaseContext(Context context) {
        super.attachBaseContext(context);
        AGConnectServicesConfig config = AGConnectServicesConfig.fromContext(context);
        config.overlayWith(new LazyInputStream(context) {
            public InputStream get(Context context) {
                try {
                    return context.getAssets().open("agconnect-services.json");
                } catch (IOException e) {
                    return null;
                }
            }
        });
    }
    // TODO: End
}
You still need to import the following classes:
Code:
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;
6. Open the AndroidManifest.xml file of your project and add the Application subclass name to the application section. If the subclass name has been added, skip this step. In the following example, add the MyApplication class name.
Code:
<application
    android:name=".MyApplication"
    …
    >
…
</application>
7. In the Eclipse IDE menu bar, click Project, then Clean.