不允许加载本地资源:ionic 3 android

我正在使用ionic 3 android build apk并尝试从文件添加图像:///storage/emulated/0/data/io.ionic.vdeovalet/cache/image.jpeg



    takePicture(sourceType) {
        try {
    // Create options for the Camera Dialog
          var options = {
            quality: 100,destinationType: this.camera.DestinationType.FILE_URI,encodingType: this.camera.EncodingType.JPEG,sourceType: sourceType,};
          this.camera.getPicture(options).then((imagePath) => {
    // Special handling for Android library
            if (this.platform.is('android') && sourceType ===
              this.camera.PictureSourceType.PHOTOLIBRARY) {
              this.filePath.resolveNativePath(imagePath)
                .then(filePath => {
                  let correctPath = filePath.substr(0,filePath.lastIndexOf('/') + 1);
                  let currentName = imagePath.substring(imagePath.lastIndexOf('/') + 1,imagePath.lastIndexOf('?'));
                  this.copyFiletoLocalDir(correctPath,currentName,this.createFileName());
                  this.lastimage = filePath;
                });
            } else {
              var currentName = imagePath.substr(imagePath.lastIndexOf('/') + 1);
              var correctPath = imagePath.substr(0,imagePath.lastIndexOf('/') + 1);
              this.copyFiletoLocalDir(correctPath,this.createFileName());
            }
          },(err) => {
            this.presentToast('Error while selecting image.');
          });


        } catch (e) {
          console.error(e);
        }


      }

错误:不允许加载本地资源
android 6.0.1

解决方法

我遇到了同样的问题,结果证明了这一点
新的离子webview插件是导致问题的原因.

插件cordova-plugin-ionic-webview @ 2.x似乎不稳定……

让它降级回到cordova-plugin-ionic-webview@1.2.1并且一切都应该工作

脚步:

1.卸载webview

ionic cordova plugins rm cordova-plugin-ionic-webview

2.安装旧的:

ionic cordova plugins add cordova-plugin-ionic-webview@1.2.1

3.清洁cordova

cordova clean android

相关文章

这篇“android轻量级无侵入式管理数据库自动升级组件怎么实现...
今天小编给大家分享一下Android实现自定义圆形进度条的常用方...
这篇文章主要讲解了“Android如何解决字符对齐问题”,文中的...
这篇文章主要介绍“Android岛屿数量算法怎么使用”的相关知识...
本篇内容主要讲解“Android如何开发MQTT协议的模型及通信”,...
本文小编为大家详细介绍“Android数据压缩的方法是什么”,内...