The minimum Android version is 4.4. Not all Kits work on 4.4, for a complete list check out the EMUI Version-Dependent Feature Site.
Supported countries
Supported devices
HMS SDK Error codes
Important notice: The Huawei HMS Core application on the device needs all permissions, otherwise the SDK won't work.
First steps:
- Log in to Huawei developer console
- Go to app gallery
- Create a project and app
- Under Project Setting add your package name
- Enable needed APIs by selecting "Manage APIs" under "Develop > Project Setting"
- Generate keystore in your Android project:
keytool -genkey -v -keystore example.keystore -alias example -keyalg RSA -keysize 2048 -validity 1000
- Add SHA-256 certificate fingerprint to your app under "Project Settings"
- Use the command
keytool -list -v -keystore keystore
to display your keystore file
- Use the command
- The configuration will take effect in ~15 minutes
- Copy the generated keystore file to the
app
directory of the project (or where you normally store it) - Configure the signing config in the app
build.gradle
file (fill in with what you set before)android { signingConfigs { release { storeFile file("example.keystore") storePassword "xxx" keyAlias "example" keyPassword "xxx" v2SigningEnabled true } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release } debug { signingConfig signingConfigs.release } } }
- Download the
agconnect-services.json
file (be sure to enable needed kits before) and add the file to theapp
directory of the project
Project integration:
- Configure the maven repository in both
buildscript
andallprojects
of project-levelbuild.gradle
buildscript{ repositories { maven { url 'http://developer.huawei.com/repo/' } } dependencies { classpath 'com.huawei.agconnect:agcp:1.5.2.300' } } allprojects { repositories { maven {url 'http://developer.huawei.com/repo/'} } }
- Add this plugin to app-level
build.gradle
fileapply plugin: 'com.huawei.agconnect'
- If needed: Configure Proguard to prevent HMS from being obfuscated
-ignorewarnings -keepattributes *Annotation* -keepattributes Exceptions -keepattributes InnerClasses -keepattributes Signature -keepattributes SourceFile,LineNumberTable -keep class com.hianalytics.android.**{*;} -keep class com.huawei.updatesdk.**{*;} -keep class com.huawei.hms.**{*;} -keep class com.huawei.agconnect.**{*;} -keep interface com.huawei.hms.analytics.type.HAEventType{*;} -keep interface com.huawei.hms.analytics.type.HAParamType{*;}
- Lastly, before any development with HMS can take place you have to add the
appid
to yourAndroidManifest.xml
. Theappid
can be retrieved in the developer console where you download theagconnect-services.json
file (see pictures above).<meta-data android:name="com.huawei.hms.client.appid" android:value="appid=YOURAPPID" />