热更新出错

  • Creator 版本:1.10

  • 目标平台: win32/android

  • 详细报错信息,包含调用堆栈:Ready for GLSL
    Ready for OpenGL 2.0
    D/jswrapper (365): Initializing V8, version: 6.0.286.52
    D/jswrapper (145): JS: 请求的 URL: https://adm.hopeandrising.com/api/wechat/js_sdk_conf
    D/jswrapper (145): JS: platform is ------> 0
    D/jswrapper (126): JS: check in platform:false
    D/jswrapper (126): JS: is ios:false
    D/jswrapper (145): JS: 浏览器类型-> null
    D/jswrapper (145): JS: 测试模式–> undefined
    libpng warning: iCCP: known incorrect sRGB profile
    D/jswrapper (145): JS: xhr is [object Object] xhr status is 201
    D/jswrapper (145): JS: xhr result:https://adm.hopeandrising.com/api/wechat/js_sdk_conf [object Object] {“code”:0,“data”:{“appId”:“wx149cbc5a722af368”,“nonceStr”:“zHjfGMKTj0nAADin”,“signature”:“65d268a675e850c0ad79def032c56dab58c15067”,“timestamp”:1561031034,“url”:“https://wechat.hopeandrising.com/web/",“jsApiList”:[“onMenuShareTimeline”,“onMenuShareAppMessage”,“onMenuShareQQ”,“onMenuShareWeibo”,"onMenuShareQZone”]}}
    D/jswrapper (145): JS: parse reuslt: [object Object]
    D/jswrapper (145): JS: 测试连接结果 [object Object]
    D/jswrapper (145): JS: wxType is false
    D/jswrapper (126): JS: AAAAAAAAA
    D/jswrapper (126): JS: LoadScene 8aWtTQSvdCp58wBazyB7KR: 243.27200000000005ms
    D/jswrapper (126): JS: I: 1.8949999999999818ms
    D/jswrapper (126): JS: AR: 0.14200000000005275ms
    D/jswrapper (126): JS: D: 0.06100000000003547ms
    D/jswrapper (126): JS: Success to load scene: db://assets/Scene/gameScene.fire
    D/jswrapper (126): JS: AP: 0.0030000000000427463ms
    D/jswrapper (126): JS: A: 250.90499999999997ms
    E/jswrapper (268): ERROR: Uncaught TypeError: this._am.setEventCallback is not a function, location: src/project.js:0:0
    STACK:
    [0]checkUpdate@src/project.js:607
    [1]emit@src/jsb_polyfill.js:4643
    [2]emitEvents@src/jsb_polyfill.js:4631
    [3]_onTouchEnded@src/jsb_polyfill.js:4261
    [4]78.r.invoke@src/jsb_polyfill.js:9320
    [5]anonymous@src/jsb_polyfill.js:9454
    [6]79.l.dispatchEvent@src/jsb_polyfill.js:9469
    [7]C@src/jsb_polyfill.js:1267
    E/jswrapper (520): [ERROR] (e:\project\courseyear\build\jsb-default\frameworks\cocos2d-x\cocos\scripting\js-bindings\jswrapper\v8\object.cpp, 520): Invoking function (12241008) failed!
    jsb: ERROR: File e:\project\courseyear\build\jsb-default\frameworks\cocos2d-x\cocos\scripting\js-bindings\manual\jsb_cocos2dx_manual.cpp: Line: 487, Function: invokeJSTouchOneByOneCallback
    invokeJSTouchOneByOneCallback call function failed!
    E/jswrapper (268): ERROR: Uncaught TypeError: this._am.setEventCallback is not a function, location: src/project.js:0:0
    STACK:
    [0]hotUpdate@src/project.js:615
    [1]emit@src/jsb_polyfill.js:4643
    [2]emitEvents@src/jsb_polyfill.js:4631
    [3]_onTouchEnded@src/jsb_polyfill.js:4261
    [4]78.r.invoke@src/jsb_polyfill.js:9320
    [5]anonymous@src/jsb_polyfill.js:9454
    [6]79.l.dispatchEvent@src/jsb_polyfill.js:9469
    [7]C@src/jsb_polyfill.js:1267
    E/jswrapper (520): [ERROR] (e:\project\courseyear\build\jsb-default\frameworks\cocos2d-x\cocos\scripting\js-bindings\jswrapper\v8\object.cpp, 520): Invoking function (121B60A0) failed!
    jsb: ERROR: File e:\project\courseyear\build\jsb-default\frameworks\cocos2d-x\cocos\scripting\js-bindings\manual\jsb_cocos2dx_manual.cpp: Line: 487, Function: invokeJSTouchOneByOneCallback
    invokeJSTouchOneByOneCallback call function failed!

  • 重现方式:用了官方热更新教程里的方法,编译win32环境,检查更新和立即更新时候出错

  • 之前哪个版本是正常的 :

  • 手机型号 :

  • 手机浏览器 :

  • 编辑器操作系统 :

  • 编辑器之前是否有其它报错 :

  • 出现概率:

  • 额外线索:

你可以用creator的模拟器断点调试看下this._am是否为null

this._am不是null,this._am.setEventCallback是undefined

我的意思是用断点调试一步步跟踪下去,了解清楚热更原理,再看看每个步骤的值。
还有看下载的范例是不是对应你当前的引擎版本。照理说
this._am = new jsb.AssetsManager("", this._storagePath, this.versionCompareHandle);


是存在这方法的

我用的ccc1.10的版本,


确实没有setEventCallback的方法,就是注册回调的地方不知道替代方案是什么

那估计范例里的api都是2.0以上的,你问下官方

需要修改的地方你看下:
// manifestUrl: cc.RawAsset, //engine 1.+
manifestUrl: { //engine 2.+
type: cc.Asset,
default: null,
},

if(Global.engine == 2) //注意是所有url相关的地方
url = this.manifestUrl.nativeUrl;
else
url = this.manifestUrl;

if(Global.engine == 2) //注意是所有注册事件的地方
this._am.setEventCallback(null);
else{
this._updateListener = new jsb.EventListenerAssetsManager(this._am,null);
cc.eventManager.addListener(this._updateListener, 1);
}

我换成2.x版本了,之前setEventCallback问题好了,现在又有了新问题,打出的win32的包,执行时候黑屏,
STACK:
[0]_activateNodeRecursively@src/cocos2d-jsb.js:23811
[1]activateNode@src/cocos2d-jsb.js:23857
[2]_activate@src/cocos2d-jsb.js:9788
[3]runSceneImmediate@src/cocos2d-jsb.js:7865
[4]anonymous@src/cocos2d-jsb.js:7945
[5]anonymous@src/cocos2d-jsb.js:26263
[6]anonymous@src/cocos2d-jsb.js:21608
[7]anonymous@src/cocos2d-jsb.js:30161
[8]fireTimeout@jsb-adapter/jsb-builtin.js:2033
[9]tick@jsb-adapter/jsb-builtin.js:1995
E/jswrapper (534): [ERROR] (f:\proj\hotupdatetest\build\jsb-default\frameworks\cocos2d-x\cocos\scripting\js-bindings\jswrapper\v8\object.cpp, 534): Invoking function (0E2FBBD8) failed!
D/jswrapper (129): JS: LoadScene fcyM87N0FJa5yQWp0BaMKY: 68.28699999999998ms
D/jswrapper (129): JS: Success to load scene: db://assets/Scene/hotupdate.fire
E/jswrapper (271): ERROR: Uncaught TypeError: Cannot read property ‘length’ of null, location: src/cocos2d-jsb.js:0:0

creator模拟器可以断点调试吗?怎么断点

请问下解决了吗?

我也出现这个问题,我是更新完毕执行 cc.game.restart() 出现的

if (needRestart) {
// this.panel.versionLab.string = JSON.parse(this.manifestUrl._$nativeAsset).version;
this._am.setEventCallback(null);
this._updateListener = null;
// Prepend the manifest’s search path
var searchPaths = jsb.fileUtils.getSearchPaths();
var newPaths = this._am.getLocalManifest().getSearchPaths();
console.log(JSON.stringify(newPaths));
Array.prototype.unshift.apply(searchPaths, newPaths);
// This value will be retrieved and appended to the default search path during game startup,
// please refer to samples/js-tests/main.js for detailed usage.
// !!! Re-add the search paths in main.js is very important, otherwise, new scripts won’t take effect.
cc.sys.localStorage.setItem(‘HotUpdateSearchPaths’, JSON.stringify(searchPaths));
jsb.fileUtils.setSearchPaths(searchPaths);

        cc.audioEngine.stopAll();
        cc.game.restart();
    }

错误
[Simulator: libpng warning: iCCP: known incorrect sRGB profile
E/jswrapper (274): ERROR: Uncaught TypeError: Cannot read property ‘length’ of null, location: src/cocos2d-jsb.js:0:0
STACK:
[0]visitNode@src/cocos2d-jsb.js:26231
[1]refreshScene@src/cocos2d-jsb.js:26252
[2]284.proto.emit@src/cocos2d-jsb.js:44772
[3]mainLoop@src/cocos2d-jsb.js:17663
[4]callback@src/cocos2d-jsb.js:17901
[5]tick@jsb-adapter/jsb-builtin.js:2156
E/jswrapper (574): [ERROR] (f:\jenkins\workspace\creator_2d\cocos2d-x-lite\windows\cocos2d-x-lite\cocos\scripting\js-bindings\jswrapper\v8\object.cpp, 574): Invoking function (11513BF0) failed!

重启之前加下面代码

cc.director.off(cc.Director.EVENT_AFTER_UPDATE);
cc.director.off(cc.Director.EVENT_AFTER_DRAW);