我已经使用Cordova(现在在Playstore上)为Android开发了一个应用,现在实现了自动更新。以下是我正在使用的插件列表
当我安装下载的APK时,它会关闭而不是显示“打开屏幕”。
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
var permissions = cordova.plugins.permissions;
permissions.checkPermission(permissions.WRITE_EXTERNAL_STORAGE, function (status) {
console.log(status);
if (!status.hasPermission) {
var errorCallback = function () {
console.log("Error: app requires storage permission");
};
permissions.requestPermission(permissions.WRITE_EXTERNAL_STORAGE,
function (status) {
if (!status.hasPermission)
errorCallback();
else {
downloadFile(fileSystem);
}
},
errorCallback);
}
else {
downloadFile(fileSystem);
}
}, null);
var downloadFile = function (fileSystem) {
var localPath = 'file:///storage/emulated/0/download/myApp.apk',
fileTransfer = new FileTransfer();
fileTransfer.download(encodeURI("URL"), localPath, function (entry){
cordova.plugins.fileOpener2.open(
entry.nativeURL,
'application/vnd.android.package-archive',
{
error : function(e) {
console.log('Error status: ' + e.status + ' - Error message: ' + e.message);
},
success : function () {
console.log('file opened successfully');
}
}
);
}, function (error) {
console.log("Error downloading the latest updates! - error: " + JSON.stringify(error));
});
};
},function ( evt ) {
console.log( "Error preparing to download the latest updates! - Err - " + evt.target.error.code );
message = "Error preparing to download the latest updates, Try again later";
});
答案 0 :(得分:-1)
为了解决此问题,您是否能够准确调试代码的哪一行最终崩溃?如果要将日志写入文件,则可以在本地调试日志,也可以使用crashlytics(https://try.crashlytics.com/)之类的工具