版本
<plugin name="cordova-hot-code-push-plugin" spec="~1.5.3" />
<engine name="android" spec="^7.1.4" />
<engine name="ios" spec="^4.5.5" />
配置
config.xml
<chcp>
<auto-download enabled="true" />
<auto-install enabled="true" />
<!--XXX代表服务器地址-->
<config-file url="https://XXX/www/chcp.json" />
</chcp>
cordova-hcp.json
{
"name": "XXX",
"autogenerated": true,
// 包名
"ios_identifier": "XXX",
"android_identifier": "XXX",
"update": "resume",
// XXX代表服务器地址
"content_url": "https://XXX/www"
}
报错
// 获取报错代码
chcp.fetchUpdate(function (error, data) {
console.log('chcp debug');
console.log('error', error);
console.log('data', data);
});
error:{ code:-4, description: " failed to download update files" }
官方解释
FAILED_TO_DOWNLOAD_UPDATE_FILES - failed to download updated/new files from the server. Check your chcp.manifest file: all listed files must be placed in the content_url from the application config. Also, check their hashes: they must match to the hashes in the chcp.manifest. Error code value is -4.(意思是线上的文件和chcp.manifest的不符合)
解决
找了一大圈 最后发现由于webpack打包多个js 在上传阿里云oss时一次性最多只能传100个文件,但是整个www文件超过了100个 所以线上只有100个文件 与chcp.manifest的文件不符合 因此失败
网友评论