MonkeyDLuffy
MonkeyDLuffy
  • 发布:2019-10-21 10:24
  • 更新:2021-07-15 11:01
  • 阅读:1724

uniapp离线打包后,openDocument报错

分类:uni-app

hbulider调试有效,离线打包报错
代码:

downloadFile(info){  
                uni.downloadFile({  
                    url: this.constApis.LAWSDOWNLOAD.URL+"?id="+info+"&tableName=2",  
                    success: function (res) {  
                        var filePath = res.tempFilePath;  
                        uni.saveFile({  
                          tempFilePath: filePath,  
                          success: function (res) {  
                            var savedFilePath = res.savedFilePath;  
                            console.log("保存文件路径:="+savedFilePath);  
                            uni.openDocument({  
                                filePath: savedFilePath,  
                                success: function (res) {  
                                    uni.showToast({  
                                        icon: 'none',  
                                        duration: 1000,  
                                        title: "chenggong=="+JSON.stringify(res)  
                                    });  
                                    console.log('打开文档成功');  
                                },  
                                fail:function (res) {  
                                    uni.showToast({  
                                        icon: 'none',  
                                        duration: 1000,  
                                        title: "shiba==="+JSON.stringify(res)  
                                    });  
                                }  
                            });  
                          }  
                        });  
                    },  
                    fail:function (res) {  
                    }  
                });  
            }

android调试报错

2019-10-21 10:24 负责人:无 分享
已邀请:
j***@163.com

j***@163.com

在离线打包的android studio里AndroidManifest.xml里application节点内部加入配置
<provider
android:name="io.dcloud.common.util.DCloud_FileProvider"
android:authorities="io.dcloud.HBuilder.dc.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/dcloud_file_provider" />
</provider>

注意, android:authorities="io.dcloud.HBuilder.dc.fileprovider"中,io.dcloud.HBuilder要修改成你自己对应的package名称,否则还是打开不了的

  • 道道123

    io.dcloud.HBuilder.dc.fileprovider这个是自己创建的文件吗?

    2020-09-23 14:31

  • 1***@qq.com

    终于解决了 谢谢!!

    2022-05-10 14:49

w***@sina.com

w***@sina.com

我只是调用uni.openDocument打开app内部的一个文件,在调试基座里打开一切正常,但是一旦打包部署到安卓手机上,这一段代码就报文件路径不存在!

  • 菜菜兔

    请问问题解决了吗?

    2019-12-13 15:48

greenboy

greenboy - 好的

请问解决了吗?我也遇到了这个问题

1***@qq.com

1***@qq.com

请问这个有办法解决吗?

该问题目前已经被锁定, 无法添加新回复