华为快游戏SDK接入踩坑记录

华为快游戏被驳回常见问题:
  1. 游戏开始前著作权人、健康游戏忠告等信息显示不全(页面停留时间不宜过短,如果过短也可能会审核不通过)
  2. 激励视频有部分请求是实时的,没有预加载
  3. 无隐私权限或者是同意隐私权限进入应用后,下次打开仍需同意(这个可以做默认勾选,用户点击同意按钮之后下次进入游戏不再出现)
  4. 原生广告没有广告来源
华为快游戏被驳回技术方面的问题:
  1. 激励视频播放完成,不发放复活奖励。
  2. 交付件中无插屏广告,出现插屏预加载
  3. 原生广告广告位与交付件不符
  4. 原生广告切换界面后返回,广告展示无曝光上报
  5. 激励视频点击无法观看
  6. 原生广告有广告请求,没有广告返回
  7. 原生页面ui无广告标识
新规则:
快游戏激励视频必选640*360尺寸和720*1280两个尺寸
去掉勾选的使用正式版签名,不使用正式版签名
1.资源加载出错:
解决方案:
(1)第一步:
libs库文件夹中,需要引入文件: laya.hwmini.js
(2)打包工具:layaIDE的版本2.8.1以上:
(3)适配华为: 文档中心
由于快游戏平台实现的  XMLHttpRequest  不支持读取本地文件,因此需要添加适配来读取本地文件。以下是对  不同 Laya 版本的适配
   // 第一处适配代码在这里,插入添加适配读取本地资源
if (typeof loadRuntime !== 'undefined' && !url.startsWith("http")) {
   let that = this;
    setTimeout(() => {
        if (url.startsWith('file://')){
            url = url.substr('file://'.length);
        }
        url = URL.getAdptedFilePath(url);//对资源后缀转化,Laya 自带方法
        var response;
        var type = contentType;
        if (type == 'pkm' || type === "arraybuffer") {
            response = qg.getFileSystemManager().readFileSync(url);
        } else {
            response = qg.getFileSystemManager().readFileSync(url, "utf8");
            if ((type == 'atlas' || type == 'json') && typeof response !== "undefined") {
                response = JSON.parse(response);
            }
        }
        that.onLoaded(response);
    }, 0);
    return;//这里记得 return
}

//第一处添加适配代码结束,下面是原本 laya 代码
 
           //第二处适配代码
            if (Browser.onVVMiniGame || typeof qg !== "undefined") {
                this._http = new HttpRequest();
            }
            else {
                if (!this._http)
                    this._http = new HttpRequest();
            }
            // if (Browser.onVVMiniGame) {
            //     this._http = new HttpRequest();
            // }
            // else {
            //     if (!this._http)
            //         this._http = new HttpRequest();
            // }

2.音效报错:华为对音效和音乐做特殊适配:
(1)播放音乐做华为适配:
      
  if (window.hbs) {//华为播放音乐
            this._bgm = hbs.createInnerAudioContext();
            this._bgm.src = file;
            this._bgm.loop = true;
            this._bgm.play();
        } else if (Laya.Browser.onMiniGame) {
            if (!this._bgm)
                this._bgm = wx.createInnerAudioContext();
            this._bgm.src = file;
            this._bgm.loop = true;
            this._bgm.play();
        } else if (window.isApp && zs.Native && window.qg) {
            if (!this._bgm)
                this._bgm = qg.createInnerAudioContext();
            this._bgm.src = file;
            this._bgm.loop = true;
            this._bgm.play();
        } else {
            if (!this._bgm)
                this._bgm = Laya.SoundManager.playMusic(file, 0, undefined, (this._bgm && this._bgm.url === file) ? this._bgm.position : 0);
        }

(2)播放音效做华为适配:
  
      if (window.hbs) {
            sound = hbs.createInnerAudioContext();
            sound.src = config.file;
            sound.loop = loop;
            sound.volume = config.musicPower * this.soundVolume;
            sound.play();
        } else {
            sound = Laya.SoundManager.playSound(config.file, loop ? 0 : 1);
            sound && power != void 0 && (sound.volume = power);
        }

3.华为屏幕适配:加在Main.js的最后:
 
//华为屏幕适配
if (typeof hbs !== 'undefined') {
    Laya.stage.useRetinalCanvas = true;
    if (typeof getAdapterInfo !== "undefined") {
        var stage = Laya.stage;
        var info = getAdapterInfo({ width: stage.designWidth, height: stage.designHeight, scaleMode: stage._scaleMode });
        //注意:其中 GameConfig.width 和 GameConfig.height 为该demo中设置游戏的宽和高,请根据实际项目填写
        stage.designWidth = info.w;
        stage.designHeight = info.h;
        stage.width = info.rw;
        stage.height = info.rh;
        stage.scale(info.scaleX, info.scaleY);
    }
}


4.必须主动在index.js中引入华为的库文件:

if (window.hbs) {  //打包华为必须主动引入
    loadLib("libs/laya.hwmini.js");
}

5.华为调用登录,失败:游戏登录失败,错误码:AUTH FAIL, code:-1
解决办法:
报-1是指纹问题。拿本地的加载器去测试下rpk,可以在加载器里看到该游戏的指纹,然后看看和AGC官网上这个应用的指纹是不是一致
长按加载器上应用,通过管理可以看到指纹
6.华为包第一次上线前,所有的广告都要使用测试ID去拉取:
测试广告id:
原生 testy63txaom86
banner testw6vs28auh3
激励 testx9dtjwj8hp
插屏 testb4znbuh3n2
7.华为隐私政策网址:
  • 43
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小春熙子

你一毛我一毛,先富带后富

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值