startCheck(){
//var storagePath = jsb.fileUtils ? jsb.fileUtils.getWritablePath() : ‘/’;
var storagePath = MultiPlatform.getInstance().getDownloadPath();
console.log('Storage path for remote asset : ' + storagePath);
this._apkPath = storagePath+'test.apk';
//var web = "http://download.hs323.com/app/hs_hzmj-release.apk";
var web = "http://cdna.wolfmedia.in/RoyalTeenpatti/xx.apk";
this.tip.string = "start download";
this.downloader = new jsb.Downloader();
this.downloader.setOnTaskError(function(sender,errorCode,errorCodeInternal,errStr){
console.log("errorCode="+errorCode);
console.log("errorCodeInternal="+errorCodeInternal);
console.log("errStr="+errStr);
//this.downloader = null;
}.bind(this));
this.downloader.setOnTaskProgress(function(sender,bytesReceived,totalBytesReceived,totalBytesExpected){
// console.log("已下载完成大小="+bytesReceived);
// console.log("总大小="+totalBytesReceived);
// console.log("预期总大小="+totalBytesExpected);
// var percent = totalBytesExpected ? totalBytesReceived * 100 / totalBytesExpected : 0;
// console.log("percent:"+percent);
// var lblDownload = cc.find("Canvas/lblDownload");
// var lblscript = lblDownload.getComponent(cc.Label);
// lblscript.string = "已经下载游戏"+ Math.floor(percent)+"%";
console.log(`getDownloadedBytes/getTotalBytes:${bytesReceived}/${totalBytesExpected}`);
let rate = totalBytesReceived/totalBytesExpected;
var percent = totalBytesExpected ? (totalBytesReceived * 100 / totalBytesExpected).toFixed(1) : 0;
this.tip.string = `update:${percent}%`;
this.progressBar.progress = rate;
}.bind(this));
this.downloader.setOnFileTaskSuccess(function(sender){
console.log("downLoad sucess!!!");
//调用安装
console.log("APK_Path",this._apkPath);
MultiPlatform.getInstance().installClient(this._apkPath);
}.bind(this));
this._bonesTask = this.downloader.createDownloadFileTask(web,this._apkPath);
}
之前用creator2.0.8 jsb.Downloader下载apk到本地断点续传是ok的。升级到2.2.2就没有断点续传了,经常下载失败每次都要重新开始下载,这个问题只出现在安卓,windows和模拟器都可以断点续传,ios没试过。随便弄个新项目复制这段代码就能出现问题。
-
Creator 版本:
-
目标平台:
-
详细报错信息,包含调用堆栈:org.cocos2d.helloworld W/System.err: java.net.SocketException: Socket closed
-
重现方式:
-
之前哪个版本是正常的 <!creator2.0.8–>:
-
手机型号 :
-
手机浏览器 :
-
编辑器操作系统 :
-
编辑器之前是否有其它报错 :
-
出现概率:必现
-
额外线索:
讲句公道话,虽然cocos官方的确会漏掉一些问题不处理,但是你一直抱怨老版本里的bug还怨官方不负责是不是有点强人所男