Cordova 文件系统root.fullPath返回未定义,root.getFile给出;processMessage失败错误“;在phonegap.js中

Cordova 文件系统root.fullPath返回未定义,root.getFile给出;processMessage失败错误“;在phonegap.js中,cordova,html5-filesystem,sencha-cmd5,senchatouch-2.4,Cordova,Html5 Filesystem,Sencha Cmd5,Senchatouch 2.4,这是我在这里的第一个问题,所以如果我写错了我的请求,很抱歉。我正在使用senchatouch2.4.1和PhoneGap(我的主要目标是Android)创建一个项目 sencha app build native 打包。简而言之,我需要请求文件系统,然后下载一些文件(图像)。根据类似的帖子,我试图在开始下载之前使用“getFile()”函数,但即使是这样一个简单的代码也会给我带来麻烦: Ext.define("MyApp.utils.Globals", { singleton: tru

这是我在这里的第一个问题,所以如果我写错了我的请求,很抱歉。我正在使用senchatouch2.4.1和PhoneGap(我的主要目标是Android)创建一个项目

sencha app build native
打包。简而言之,我需要请求文件系统,然后下载一些文件(图像)。根据类似的帖子,我试图在开始下载之前使用“getFile()”函数,但即使是这样一个简单的代码也会给我带来麻烦:

Ext.define("MyApp.utils.Globals", {
    singleton: true,
    alias: 'widget.globals',
    config: {
        // Some vars not related to problem
    },
    constructor: function(config) {
        this.initConfig(config);
    },
    initFileSystem: function(quota) {
        if(Ext.browser.is.PhoneGap && !Ext.os.is.Desktop) {
            Ext.device.FileSystem.requestFileSystem({     
                type: window.PERSISTENT,
                size: quota,
                success: this.initFsSuccess,
                failure: this.initFsFailure
            });
        } else {
            window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
            window.requestFileSystem(window.PERSISTENT, quota, this.initFsSuccess, this.initFsFailure);
        }
    },
    initFsSuccess: function(fs) {
        // Save file system reference
        MyApp.app.fS = fs;      
        alert("FS: " + fs.root.fullPath); // This line outputs "FS: undefined"
        fs.root.getFile("newFile.jpg", {create: true, exclusive: false}, function(fileEntry){ alert("GetFile OK"); }, function(error){ alert("GetFile ERR"); });
    },
    initFsFailure: function(err) {
        console.log("File System Error " + err.code);
        Ext.Msg.show({
            title: 'FyleSystem Error',
            message: 'Can\'t access to FileSystem',
            buttons: [ { itemId: 'ok', text: 'Ok', ui: 'decline' } ],
            fn: Ext.emptyFn
        });
    }
});
当我尝试访问文件系统的根完整路径时(如“initFsSuccess”函数中的第一个警报),我得到
undefined
作为值。此外,“getFile”函数停止执行(无论成功与否,都不会调用回调),在LogCat中,我可以看到:

01-12 12:22:20.669: D/CordovaLog(1625): file:///android_asset/www/phonegap.js: Line 1059 : processMessage failed: Error: TypeError: Cannot call method 'error' of undefined
01-12 12:22:20.669: I/Web Console(1625): processMessage failed: Error: TypeError: Cannot call method 'error' of undefined at file:///android_asset/www/phonegap.js:1059
01-12 12:22:20.669: D/CordovaLog(1625): file:///android_asset/www/phonegap.js: Line 1060 : processMessage failed: Stack: TypeError: Cannot call method 'error' of undefined
01-12 12:22:20.669: D/CordovaLog(1625):     at [object Object].getFile (file:///android_asset/www/app.js:1:498661)
01-12 12:22:20.669: D/CordovaLog(1625):     at [object Object].<anonymous> (file:///android_asset/www/app.js:1:617018)
01-12 12:22:20.669: D/CordovaLog(1625):     at file:///android_asset/www/app.js:1:495077
01-12 12:22:20.669: D/CordovaLog(1625):     at file:///android_asset/www/plugins/org.apache.cordova.file/www/requestFileSystem.js:52:25
01-12 12:22:20.669: D/CordovaLog(1625):     at success (file:///android_asset/www/plugins/org.apache.cordova.file/www/fileSystems-roots.js:40:13)
01-12 12:22:20.669: D/CordovaLog(1625):     at Object.callbackFromNative (file:///android_asset/www/phonegap.js:293:54)
01-12 12:22:20.669: D/CordovaLog(1625):     at processMessage (file:///android_asset/www/phonegap.js:1054:21)
01-12 12:22:20.669: D/CordovaLog(1625):     at Function.processMessages (file:///android_asset/www/phonegap.js:1091:13)
01-12 12:22:20.669: D/CordovaLog(1625):     at pollOnce (file:///android_asset/www/phonegap.js:956:17)
01-12 12:22:20.669: D/CordovaLog(1625):     at pollOnceFromOnlineEvent (file:///android_asset/www/phonegap.js:946:5)
01-12 12:22:20.669: I/Web Console(1625): processMessage failed: Stack: TypeError: Cannot call method 'error' of undefined
01-12 12:22:20.669: I/Web Console(1625):     at [object Object].getFile (file:///android_asset/www/app.js:1:498661)
01-12 12:22:20.669: I/Web Console(1625):     at [object Object].<anonymous> (file:///android_asset/www/app.js:1:617018)
01-12 12:22:20.669: I/Web Console(1625):     at file:///android_asset/www/app.js:1:495077
01-12 12:22:20.669: I/Web Console(1625):     at file:///android_asset/www/plugins/org.apache.cordova.file/www/requestFileSystem.js:52:25
01-12 12:22:20.669: I/Web Console(1625):     at success (file:///android_asset/www/plugins/org.apache.cordova.file/www/fileSystems-roots.js:40:13)
01-12 12:22:20.669: I/Web Console(1625):     at Object.callbackFromNative (file:///android_asset/www/phonegap.js:293:54)
01-12 12:22:20.669: I/Web Console(1625):     at processMessage (file:///android_asset/www/phonegap.js:1054:21)
01-12 12:22:20.669: I/Web Console(1625):     at Function.processMessages (file:///android_asset/www/phonegap.js:1091:13)
01-12 12:22:20.669: I/Web Console(1625):     at pollOnce (file:///android_asset/www/phonegap.js:956:17)
01-12 12:22:20.669: I/Web Console(1625):     at pollOnceFromOnlineEvent (file:///android_asset/www/phonegap.js:946:5) at file:///android_asset/www/phonegap.js:1060
01-12 12:22:20.669: D/CordovaLog(1625): file:///android_asset/www/phonegap.js: Line 1061 : processMessage failed: Message: S01 File1432781697 [{"fullPath":"\/","filesystemName":"temporary","isDirectory":true,"nativeURL":"file:\/\/\/mnt\/sdcard\/Android\/data\/com.mysite.MyApp\/cache\/","filesystem":0,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"persistent","isDirectory":true,"nativeURL":"file:\/\/\/mnt\/sdcard\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"content","isDirectory":true,"nativeURL":"cdvfile:\/\/localhost\/content\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"files","isDirectory":true,"nativeURL":"file:\/\/\/data\/data\/com.mysite.MyApp\/files\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"files-external","isDirectory":true,"nativeURL":"file:\/\/\/mnt\/sdcard\/Android\/data\/com.mysite.MyApp\/files\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"documents","isDirectory":true,"nativeURL":"file:\/\/\/data\/data\/com.mysite.MyApp\/files\/Documents\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"sdcard","isDirectory":true,"nativeURL":"file:\/\/\/mnt\/sdcard\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"cache","isDirectory":true,"nativeURL":"file:\/\/\/data\/data\/com.mysite.MyApp\/cache\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"cache-external","isDirectory":true,"nativeURL":"file:\/\/\/mnt\/sdcard\/Android\/data\/com.mysite.MyApp\/cache\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"root","isDirectory":true,"nativeURL":"file:\/\/\/","filesystem":1,"isFile":false,"name":""}]
01-12 12:22:20.669: I/Web Console(1625): processMessage failed: Message: S01 File1432781697 [{"fullPath":"\/","filesystemName":"temporary","isDirectory":true,"nativeURL":"file:\/\/\/mnt\/sdcard\/Android\/data\/com.mysite.MyApp\/cache\/","filesystem":0,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"persistent","isDirectory":true,"nativeURL":"file:\/\/\/mnt\/sdcard\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"content","isDirectory":true,"nativeURL":"cdvfile:\/\/localhost\/content\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"files","isDirectory":true,"nativeURL":"file:\/\/\/data\/data\/com.mysite.MyApp\/files\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"files-external","isDirectory":true,"nativeURL":"file:\/\/\/mnt\/sdcard\/Android\/data\/com.mysite.MyApp\/files\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"documents","isDirectory":true,"nativeURL":"file:\/\/\/data\/data\/com.mysite.MyApp\/files\/Documents\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"sdcard","isDirectory":true,"nativeURL":"file:\/\/\/mnt\/sdcard\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"cache","isDirectory":true,"nativeURL":"file:\/\/\/data\/data\/com.mysite.MyApp\/cache\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"cache-external","isDirectory":true,"nativeURL":"file:\/\/\/mnt\/sdcard\/Android\/data\/com.mysite.MyApp\/cache\/","filesystem":1,"isFile":false,"name":""},{"fullPath":"\/","filesystemName":"root","isDirectory":true,"nativeURL":"file:\/\/\/","filesystem":1,"isFile":false,"name":""}] at file:///android_asset/www/phonegap.js:1061
01-12:22:20.669:D/CordovaLog(1625):file:///android_asset/www/phonegap.js: 第1059行:processMessage失败:错误:TypeError:无法调用未定义的方法“Error”
01-12 12:22:20.669:I/Web控制台(1625):processMessage失败:错误:TypeError:无法调用在处未定义的方法“Error”file:///android_asset/www/phonegap.js:1059
01-12 12:22:20.669:D/CordovaLog(1625):file:///android_asset/www/phonegap.js: 第1060行:processMessage失败:堆栈:类型错误:无法调用未定义的方法“error”
01-12 12:22:20.669:D/CordovaLog(1625):在[object object].getFile(file:///android_asset/www/app.js:1:498661)
01-12 12:22:20.669:D/CordovaLog(1625):在[object]。(file:///android_asset/www/app.js:1:617018)
01-12 12:22:20.669:D/CordovaLog(1625):在file:///android_asset/www/app.js:1:495077
01-12 12:22:20.669:D/CordovaLog(1625):在file:///android_asset/www/plugins/org.apache.cordova.file/www/requestFileSystem.js:52:25
01-12:22:20.669:D/CordovaLog(1625):成功(file:///android_asset/www/plugins/org.apache.cordova.file/www/fileSystems-roots.js:40:13)
01-12 12:22:20.669:D/CordovaLog(1625):at Object.callbackromnative(file:///android_asset/www/phonegap.js:293:54)
01-12 12:22:20.669:D/CordovaLog(1625):在处理消息时(file:///android_asset/www/phonegap.js:1054:21)
01-12 12:22:20.669:D/CordovaLog(1625):在Function.processMessages(file:///android_asset/www/phonegap.js:1091:13)
01-12:22:20.669:D/科多瓦洛格(1625):立刻(file:///android_asset/www/phonegap.js:956:17)
01-12:22:20.669:D/CordovaLog(1625):在PollonceFromonLine事件中(file:///android_asset/www/phonegap.js:946:5)
01-12 12:22:20.669:I/Web控制台(1625):processMessage失败:堆栈:类型错误:无法调用未定义的
01-12 12:22:20.669:I/Web控制台(1625):位于[object object].getFile(file:///android_asset/www/app.js:1:498661)
01-12 12:22:20.669:I/Web控制台(1625):位于[object]。(file:///android_asset/www/app.js:1:617018)
01-12 12:22:20.669:I/Web控制台(1625):在file:///android_asset/www/app.js:1:495077
01-12 12:22:20.669:I/Web控制台(1625):在file:///android_asset/www/plugins/org.apache.cordova.file/www/requestFileSystem.js:52:25
01-12:22:20.669:I/Web控制台(1625):成功(file:///android_asset/www/plugins/org.apache.cordova.file/www/fileSystems-roots.js:40:13)
01-12 12:22:20.669:I/Web控制台(1625):at Object.callbackromnative(file:///android_asset/www/phonegap.js:293:54)
01-12 12:22:20.669:I/Web控制台(1625):at进程消息(file:///android_asset/www/phonegap.js:1054:21)
01-12 12:22:20.669:I/Web控制台(1625):位于Function.processMessages(file:///android_asset/www/phonegap.js:1091:13)
01-12:22:20.669:I/Web控制台(1625):立即(file:///android_asset/www/phonegap.js:956:17)
01-12 12:22:20.669:I/Web控制台(1625):在pollOnceFromOnlineEvent(file:///android_asset/www/phonegap.js:946:5)在file:///android_asset/www/phonegap.js:1060
01-12 12:22:20.669:D/CordovaLog(1625):file:///android_asset/www/phonegap.js: 第1061行:processMessage失败:消息:S01文件1432781697[{“完整路径”:“\/”,“文件系统名称”:“临时”,“isDirectory”:true,“nativeURL”:“文件:\/\/\/mnt\/sdcard\/Android\/data\/com.mysite.MyApp\/cache\/”,“文件系统”:0,“isFile”:false,“name”:“},{“完整路径”:“\/”,“filesystemName:“persistent”,“isDirectory:”true,“nativeURL:”file:\/\/\/mnt\/sdcard\/“,”filesystem:”1,“isFile:”false,“name:”},{“fullPath:”name:“\/”,”filesystemName:”content”,“isDirectory:”true,“nativeURL:”cdvfile:\/\/\/localhost\/content\/“,”filesystem:”1,“isFile:”false,“name:”name:”files:”files:“files”,“isDirectory:”true,”nativeURL:“文件:\/\/\/data\/data\/com.mysite.MyApp\/files\/”,“文件系统”:1,“isFile”:false,“name”:“},{”fullPath:“\/”,“filesystemName”:“files external”,“isDirectory”:true,“nativeURL:“file:\/\/\/mnt\/sdcard\/Android\/data\/com.mysite.MyApp\/files\/”,“文件系统”:1,“isFile”:false,“name”:“},{”fullPath:“/”,“filesystemName”:“,“filesystemName”:“documents”,”isDirectory“:true,“nativeURL”:“file:\/\/\/data\/data\/com.mysite.MyApp\/files\/Documents\/”,“filesystem”:1,“isFile”:false,“name”:“},{“fullPath”:“\/”,“filesystemName”:“sdcard”,“isDirectory”:true,“nativeURL”:“file:\/\/\/\/mnt\/sdcard\/”,“filesystem”:1,“isFile:”false,“name”:“,{“fullPath”:“,“filesystemName”:“cache”,“isDirectory”:“cache”,“isDirectory”:“nativeURL”:”文件:\/\/\/data\/data\/com.mysite.MyApp\/cache\/”,“文件系统”:1,“isFile”:false,“名称”:“},{fullPath”:“\/”,“filesystemName”:“缓存外部”,“isDirectory”:true,“nativeURL”:“文件:\/\/mnt\/sdcard\/Android\/data\/com.mysite.MyApp\/cache\/”,“文件系统”:1,“isFile”:false,“名称”:“},{”fullPath:“,“filesystemName”:“,“filesystemName”:“root”,“isDirectory”:“:”true,“,“filesystemName”:”nativeURL:“文件:\/\/\/”,“文件系统”:1,“isFile”:false,“名称”:“}]
01-12 12:22:20.669:I/Web控制台(1625):processMessage失败:消息:S01文件1432781697[{“完整路径”:“\/”,“文件系统名”:“临时”,“isDirectory”:true,“nativeURL”:“文件:\/\/mnt\/sdcard\/Android\/data\/com.mysite.MyApp\/cache\/”,“文件系统”:0,“isFile”:false,“名称”:“,“{”完整路径“\/”,“文件系统名”:“持久”,“isDirectory”:true,”nativeU
'Ext.device.FileSystem'
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem(window.PERSISTENT, quota, this.initFsSuccess, this.initFsFailure);