统一IM方案,Android端sdk
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

华为sdk集成.md 4.2KB

1 jaar geleden
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. - ##### 根据[华为推送服务配置文档](https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/android-config-agc-0000001050170137)完成应用创建和推送服务的开通
  2. - ##### 登录[AppGallery Connect](https://developer.huawei.com/consumer/cn/service/josp/agc/index.html)网站,点击“我的项目”。
  3. - ##### 在项目列表中找到您的项目,在项目中点击需要集成HMS Core SDK的应用。
  4. - ##### 在“项目设置 > 常规”页面的“应用”区域,点击“agconnect-services.json”下载配置文件。
  5. ![点击放大](https://alliance-communityfile-drcn.dbankcdn.com/FileServer/getFile/cmtyPub/011/111/111/0000000000011111111.20230221102806.12268288190126774767350517557615:50001231000000:2800:12ABACEF3849B9BA1E7CDABD51E96D6851FABECD55E05713EAAC7B0A487F73E1.png?needInitFileName=true?needInitFileName=true)
  6. - ##### 将“agconnect-services.json”文件拷贝到应用级根目录下。
  7. ![img](https://alliance-communityfile-drcn.dbankcdn.com/FileServer/getFile/cmtyPub/011/111/111/0000000000011111111.20230221102806.48189746150828014962362521369272:50001231000000:2800:A389367A1252831B6E662C4D5340473CB088CB9B317B4418003379F782052999.png?needInitFileName=true?needInitFileName=true)
  8. - ##### 配置HMS Core SDK的Maven仓地址
  9. Android Studio的代码库配置在Gradle插件7.0以下版本、7.0版本和7.1及以上版本有所不同。请根据您当前的Gradle插件版本,选择对应的配置过程。
  10. | [7.0以下版本](https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/android-integrating-sdk-0000001050040084#ZH-CN_TOPIC_0000001087049212__zh-cn_topic_0000001050041594_li547444421611) | [7.0版本](https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/android-integrating-sdk-0000001050040084#ZH-CN_TOPIC_0000001087049212__zh-cn_topic_0000001050041594_li1796424071918) | [7.1及以上版本](https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/android-integrating-sdk-0000001050040084#ZH-CN_TOPIC_0000001087049212__zh-cn_topic_0000001050041594_li1345452582116) |
  11. | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
  12. | | | |
  13. - ##### 添加AGC插件配置。请根据实际情况选择:
  14. - 方式一:在文件头部声明下一行添加如下配置。
  15. ```groovy
  16. apply plugin: 'com.huawei.agconnect'
  17. ```
  18. - 方式二:在`plugins`中添加如下配置
  19. ```groovy
  20. plugins { id 'com.android.application' // 添加如下配置 id 'com.huawei.agconnect'}
  21. ```
  22. - ##### 配置签名
  23. 将[生成签名证书指纹](https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/android-config-agc-0000001050170137#section193351110105114)步骤中生成的签名文件拷贝到工程的app目录下,在build.gradle文件中配置签名。
  24. ```groovy
  25. android {
  26. signingConfigs {
  27. config {
  28. // 根据您实际的签名信息,替换以下参数中的xxxx
  29. keyAlias 'xxxx'
  30. keyPassword 'xxxx'
  31. storeFile file('xxxx.jks')
  32. storePassword 'xxxx'
  33. }
  34. }
  35. buildTypes {
  36. debug {
  37. signingConfig signingConfigs.config
  38. }
  39. release {
  40. signingConfig signingConfigs.config
  41. minifyEnabled false
  42. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  43. }
  44. }
  45. }
  46. ```
  47. - ## 同步工程
  48. 在完成以上的配置后,点击工具栏中的gradle同步图标完成“build.gradle”文件的同步,然后将相关依赖下载到本地。
  49. ![img](https://alliance-communityfile-drcn.dbankcdn.com/FileServer/getFile/cmtyPub/011/111/111/0000000000011111111.20230221102807.71643474582974097971276481469874:50001231000000:2800:6E12E277C5CE78BD6042495DB9A695384BAEAFA3301E04B4BB0EBED6FB371E4A.png?needInitFileName=true?needInitFileName=true)