写不完
写不完
  • 发布:2023-05-22 20:17
  • 更新:2023-05-26 19:38
  • 阅读:643

uniapp 使用apk热更新 plus.runtime.install报错: WGT/WGTU文件格式错误

分类:HTML5+

后端给予的git请求:http://xxx.xxx.xxx.xxx:8088/file/download?filePath=/file/V1.3.0.apk

doUpData(fileId, url) {  
            let downUrl = 'http://xxx.xxx.xxx.xxx:8088/file/download?filePath=' + this.urls;  
            let downLoader = plus.downloader.createDownload(  
                downUrl,  
                {  
                    // 新建下载任务  
                    filename: '_doc/update/'  
                },  
                function(d, status) {  
                    if (status == 200) {  
                        // 下载成功  
                        plus.nativeUI.showWaiting('正在安装...');  
                        // 安装wgt包  
                        plus.runtime.install(  
                            d.filename,  
                            {},  
                            function() {  
                                plus.nativeUI.closeWaiting();  
                                plus.nativeUI.toast('应用资源更新完成', function() {  
                                    plus.runtime.restart();  
                                });  
                            },  
                            function(e) {  
                                console.log(e);  
                                plus.nativeUI.toast('安装apk文件失败[' + e.code + ']:' + e.message);  
                            }  
                        ); // 安装wgt包  
                    } else {  
                        plus.nativeUI.alert('下载apk安装包失败!');  
                    }  
                }  
            );  
            downLoader.start(); // 开始下载  
            let showLoading = plus.nativeUI.showWaiting('正在下载安装包'); // 提示框  
            // 下载进度条  
            let prg = 0;  
            downLoader.addEventListener('statechanged', function(task, status) {  
                switch (task.state) {  
                    case 1:  
                        showLoading.setTitle('正在下载');  
                        break;  
                    case 2:  
                        showLoading.setTitle('已连接到服务器');  
                        break;  
                    case 3:  
                        prg = parseInt((parseFloat(task.downloadedSize) / parseFloat(task.totalSize)) * 100);  
                        showLoading.setTitle(' 正在下载' + prg + '% ');  
                        break;  
                    case 4:  
                        plus.nativeUI.closeWaiting();  
                        break;  
                }  
            });  
        },

已经在android-permissions 内添加
"<uses-permission android:name=\"android.permission.INSTALL_PACKAGES\"/>",
"<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\"/>"

安装APK文件失败[-1202]:WGT安装包中manifest.json文件不存在。wgt文件正常

有大佬遇到过类似的情况吗?跪求解决方案~~

2023-05-22 20:17 负责人:无 分享
已邀请:
DCloud_App_Array

DCloud_App_Array

从错误信息看可能是保存文件为.wgt格式了,在手机查看下在后文件保存的名称后续必须为.apk

要回复问题请先登录注册