cordova-camera-plugin错误java.lang.NumberFormatException

时间:2019-01-22 18:24:27

标签: cordova phonegap genymotion numberformatexception cordova-plugin-camera

我正在开发在genymotion模拟器中运行的cordova应用程序。如果我选择用模拟器相机拍摄的普通图像,则一切正常。当我尝试选择在模拟器中导入的一些图像时,它们会因错误而崩溃

Process: com.phonegap.helloworld, PID: 1973
java.lang.NumberFormatException: For input string: "raw:/storage/emulated/0/Download/provaa.jpg"
    at java.lang.Long.parseLong(Long.java:590)
    at java.lang.Long.valueOf(Long.java:804)
    at org.apache.cordova.camera.FileHelper.getRealPathFromURI_API11_And_Above(FileHelper.java:101)
    at org.apache.cordova.camera.FileHelper.getRealPath(FileHelper.java:60)
    at org.apache.cordova.camera.CameraLauncher.processResultFromGallery(CameraLauncher.java:682)
    at org.apache.cordova.camera.CameraLauncher.access$000(CameraLauncher.java:74)
    at org.apache.cordova.camera.CameraLauncher$1.run(CameraLauncher.java:830)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
    at java.lang.Thread.run(Thread.java:764)

用于选择图像的代码是

 function selectImage(){
    navigator.camera.getPicture(onSuccess, onFail, {
        sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
        destinationType: Camera.DestinationType.DATA_URL
    });

    function onSuccess(imageData) {
        let image = document.getElementById('myImage');     
        image.src = "data:image/jpeg;base64," + imageData;
        imagepost= imageData;            
    }

    function onFail(message) {
        alert('Failed because: ' + message);
    }
}

有什么解决方法的想法吗?

0 个答案:

没有答案