华为

模块引入

    implementation WB.fixVersions('Pay:Huawei')

配置文件说明

根目录 build.gradle中需添加:

buildscript {
    repositories {
        google()
        jcenter()
        maven {url 'http://developer.huawei.com/repo/'}
    }
    dependencies {
         ...
        classpath 'com.huawei.agconnect:agcp:1.3.1.300'   
    }
}

allprojects {
    repositories {
        ...
        maven {url 'http://developer.huawei.com/repo/'}
    }

    ...
}

app目录 build.gradle中需添加:

apply plugin: 'com.huawei.agconnect'  //引入华为插件    需要商务提供 agconnect-services.json 文件,不然会报错


manifestPlaceholders = [
                ...
                HWCpId:"",// 华为商户id
                HWAppId:"",// 华为应用id
        ]

assets目录加入feedata_huawei.xml

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <!--计费点-->
    <feeinfo>
        <ID>1101</ID>
        <price>1</price>
        <desc>测试华为计费</desc>
    </feeinfo>
</data>

混淆过滤

#华为
-keep class com.huawei.**
-keep class com.huawei.**{*;}
-keep class com.android.huawei.**
-keep class com.android.huawei.**{*;}
-keep class com.hianalytics.**
-keep class com.hianalytics.**{*;}
-ignorewarning
-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.gamebox.plugin.gameservice.**{*;}
-keep public class com.huawei.android.hms.agent.** extends android.app.Activity { public *; protected *; }
-keep interface com.huawei.android.hms.agent.common.INoProguard {*;}
-keep class * extends com.huawei.android.hms.agent.common.INoProguard {*;}

集成测试

1.如何判断sdk是否初始化成功?

可通过名为"HuaweiAgent"的Tag查看日志,登陆成功会有“game login: onResult: retCode=”等日志输出。

2.官方错误码参考文档 https://developer.huawei.com/consumer/cn/service/hms/catalog/HuaweiJointOperation.html?page=hmssdk_jointOper_api_reference_errorcode

最后更新于