java.net.MalformedURLException:没有为此URL安装处理程序

时间:2014-02-18 10:17:33

标签: android cordova phonegap-plugins

在PhoneGap V 3.3应用程序中,我使用此功能将文件下载到设备 我添加了文件和文件传输插件并完成了所有配置

downloadAgendaPage = function () {
var uri = encodeURI("http://*****/data/***.ics");
window.requestFileSystem(
    LocalFileSystem.PERSISTENT, 0,
    function onFileSystemSuccess(fileSystem) {
        fileSystem.root.getFile(
            "dummy.pdf", { create: true, exclusive: false },
                function gotFileEntry(fileEntry) {
                    var sPath = fileEntry.fullPath.replace("dummy.pdf", "");
                    var fileTransfer = new FileTransfer();
                    fileEntry.remove();

                    fileTransfer.download(
                            uri,
                            sPath + 'Agenda.ics',
                            function (theFile) {
                                console.log("download complete: " + theFile.toURI());
                                //showLink(theFile.toURI());
                                alertify.alert("Agenda file " + "Agenda.ics" + " downloaded to your root folder");
                            },
                            function (error) {
                                console.log("download error source " + error.source);
                                console.log("download error target " + error.target);
                                console.log("upload error code: " + error.code);
                            }
                    );
                },
            fail);
    },
    fail);}

我正在调试运行Android 4.4.2的nexus 7上的应用程序,我收到此错误消息

02-18 12:04:32.514: W/System.err(21031): java.net.MalformedURLException: No installed handlers for this URL
02-18 12:04:32.514: W/System.err(21031):    at org.apache.cordova.file.FileUtils.getFile(FileUtils.java:684)
02-18 12:04:32.514: W/System.err(21031):    at org.apache.cordova.file.FileUtils.access$5(FileUtils.java:679)
02-18 12:04:32.514: W/System.err(21031):    at org.apache.cordova.file.FileUtils$16.run(FileUtils.java:349)
02-18 12:04:32.514: W/System.err(21031):    at org.apache.cordova.file.FileUtils$24.run(FileUtils.java:473)
02-18 12:04:32.514: W/System.err(21031):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
02-18 12:04:32.514: W/System.err(21031):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
02-18 12:04:32.514: W/System.err(21031):    at java.lang.Thread.run(Thread.java:841)

任何帮助,请

1 个答案:

答案 0 :(得分:1)

这个奇怪错误的原因是我手动更新了cordova-plugins.js文件并手动添加了插件js文件,因为它们没有自动添加。 为什么他们没有自动添加?因为我做错了..

答案是不构建然后添加插件,而是添加插件然后构建然后用你的文件替换www文件。