fileSystem.root.getDirectory和fileSystem.root.getFile扔java.net.MalformedURLException:没有安装处理此网址 [英] fileSystem.root.getDirectory and fileSystem.root.getFile threw java.net.MalformedURLException: No installed handlers for this URL
问题描述
3.3的PhoneGap插件文件和我一起在Android不工作,我尝试的GetFile和getDirectory,并保持给我异常
12月2日至20日:24:34.997:W / System.err的(32109):java.net.MalformedURLException:没有安装处理此网址
十二月2日至20日:24:34.997:W / System.err的(32109):在org.apache.cordova.file.FileUtils.getFile(FileUtils.java:684)
十二月2日至20日:24:35.007:W / System.err的(32109):在org.apache.cordova.file.FileUtils.access $ 5(FileUtils.java:679)
十二月2日至20日:24:35.007:W / System.err的(32109):在org.apache.cordova.file.FileUtils $ 16.run(FileUtils.java:349)
十二月2日至20日:24:35.017:W / System.err的(32109):在org.apache.cordova.file.FileUtils $ 24.run(FileUtils.java:473)
十二月2日至20日:24:35.017:W / System.err的(32109):在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
十二月2日至20日:24:35.017:W / System.err的(32109):在java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:587)
十二月2日至20日:24:35.017:W / System.err的(32109):在java.lang.Thread.run(Thread.java:841)
JavaScript的code
downloadAgendaPage =功能(){
window.requestFileSystem(LocalFileSystem.PERSISTENT,0,gotFS,失败);
}功能gotFS(文件系统){
的console.log(Emaish:文件系统要求);
的console.log(Emaish:fileStream.name =+ fileSystem.name);
的console.log(Emaish:fileStream.root.name =+ fileSystem.root.name);
fileSystem.root.getFile(的text.txt,{创建:真实,独家:假},gotFileEntry,失败);
}功能gotFileEntry(FileEntry的){
的console.log(Emaish:文件得到);
VAR URI = EN codeURI(HTTP://****/data/MYOEB2013_Agenda.ics);
的console.log(Emaish:URI:+ URI);
变种SPATH = fileEntry.fullPath.replace(的text.txt,Agenda.ics);
的console.log(Emaish:SPATH:+ SPATH);
fileEntry.remove();
VAR文件传输=新的文件传输();
fileTransfer.download(
URI,
SPATH,
功能(theFile){
的console.log(下载完成:+ theFile.toURI());
// showLink(theFile.toURI());
alertify.alert(议程下载到+ theFile.toURI());
},
功能(错误){
的console.log(下载错误源+ error.source);
的console.log(下载错误目标+ error.target);
的console.log(上传错误code:+错误code);
}
);
}
CONSOLE.LOG结果
16 02-20:15:37.205:I /铬(23491):[信息:控制台(59)]Emaish:文件系统要求,来源:文件:/// android_asset / WWW / JS / agenda.js(59)
02-20 16:15:37.205:I /铬(23491):[信息:控制台(60)]Emaish:fileStream.name =执着,来源:文件:///android_asset/www/js/agenda.js (60)
02-20 16:15:37.205:I /铬(23491):[信息:控制台(61)]Emaish:fileStream.root.name =来源:文件:/// android_asset / WWW / JS /议程。爵士(61)
这样做的原因奇怪的错误是,我是手动更新科尔多瓦 - plugins.js文件,手动添加插件js文件,因为他们没有自动添加。
为什么他们没有被自动添加?因为我是做错了。
答案是不建然后添加插件,而不是添加插件,然后建立然后用你的WWW替换文件。
PhoneGap 3.3 file plugin not working with me on Android, i tried getFile and getDirectory, and keep giving me Exception
02-20 12:24:34.997: W/System.err(32109): java.net.MalformedURLException: No installed handlers for this URL
02-20 12:24:34.997: W/System.err(32109): at org.apache.cordova.file.FileUtils.getFile(FileUtils.java:684)
02-20 12:24:35.007: W/System.err(32109): at org.apache.cordova.file.FileUtils.access$5(FileUtils.java:679)
02-20 12:24:35.007: W/System.err(32109): at org.apache.cordova.file.FileUtils$16.run(FileUtils.java:349)
02-20 12:24:35.017: W/System.err(32109): at org.apache.cordova.file.FileUtils$24.run(FileUtils.java:473)
02-20 12:24:35.017: W/System.err(32109): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
02-20 12:24:35.017: W/System.err(32109): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
02-20 12:24:35.017: W/System.err(32109): at java.lang.Thread.run(Thread.java:841)
JavaScript Code
downloadAgendaPage = function () {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function gotFS(fileSystem) {
console.log("Emaish: FileSystem Requested");
console.log("Emaish: fileStream.name = " + fileSystem.name);
console.log("Emaish: fileStream.root.name = " + fileSystem.root.name);
fileSystem.root.getFile("text.txt", {create: true, exclusive: false}, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
console.log("Emaish: File Gotten");
var uri = encodeURI("http://****/data/MYOEB2013_Agenda.ics");
console.log("Emaish: uri:" + uri);
var sPath = fileEntry.fullPath.replace("text.txt", "Agenda.ics");
console.log("Emaish: sPath:" + sPath);
fileEntry.remove();
var fileTransfer = new FileTransfer();
fileTransfer.download(
uri,
sPath,
function (theFile) {
console.log("download complete: " + theFile.toURI());
//showLink(theFile.toURI());
alertify.alert("Agenda downloaded to " + theFile.toURI());
},
function (error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code: " + error.code);
}
);
}
Console.log Result
02-20 16:15:37.205: I/chromium(23491): [INFO:CONSOLE(59)] "Emaish: FileSystem Requested", source: file:///android_asset/www/js/agenda.js (59)
02-20 16:15:37.205: I/chromium(23491): [INFO:CONSOLE(60)] "Emaish: fileStream.name = persistent", source: file:///android_asset/www/js/agenda.js (60)
02-20 16:15:37.205: I/chromium(23491): [INFO:CONSOLE(61)] "Emaish: fileStream.root.name = ", source: file:///android_asset/www/js/agenda.js (61)
The reason for this strange error is that i was manually updating the cordova-plugins.js file and manually adding the plugins js files, because they were n't added automatically. Why they weren't added automatically? because i was doing it wrong ..
The Answer is don't build then add the plugins, instead add the plugin then build then replace www files with yours.
这篇关于fileSystem.root.getDirectory和fileSystem.root.getFile扔java.net.MalformedURLException:没有安装处理此网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!