sencha touch与phonegap(使用sencha cmd和phonegap构建)导致错误:LocalFileSystem未定义 [英] sencha touch with phonegap (using sencha cmd and phonegap build) causes Error : LocalFileSystem not defined

查看:145
本文介绍了sencha touch与phonegap(使用sencha cmd和phonegap构建)导致错误:LocalFileSystem未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照这些sencha cmd指南,产生一个基于phoneGap的sencha touch 2项目:
使用最新的Sencha Cmd v4.0.2.67,最新sencha触摸2.3.1,phoneGap ver-3.1.0



1)按以下方式制作sencha touch 2项目:

  sencha -sdk / path / to / sencha-touch-sdk generate app MyApp / path / to / www / myapp 

2)将phoneGap添加到上述项目

  sencha phonegap init 

3)配置phonegap.local.properties

  phonegap.platform = android 
phonegap.build.remote = true
phonegap.build.remote.username = myUseName
phonegap .build.remote.password = myPassword

4)更新了配置。添加所有核心插件添加所有核心插件

 < 
< gap:plugin name =org.apache.cordova.battery-status/>
< gap:plugin name =org.apache.cordova.camera/>
< gap:plugin name =org.apache.cordova.media-capture/>
< gap:plugin name =org.apache.cordova.console/>
< gap:plugin name =org.apache.cordova.contacts/>
< gap:plugin name =org.apache.cordova.device/>
< gap:plugin name =org.apache.cordova.device-motion/>
< gap:plugin name =org.apache.cordova.device-orientation/>
< gap:plugin name =org.apache.cordova.dialogs/>
< gap:plugin name =org.apache.cordova.file/>
< gap:plugin name =org.apache.cordova.file-transfer/>
< gap:plugin name =org.apache.cordova.geolocation/>
< gap:plugin name =org.apache.cordova.globalization/>
< gap:plugin name =org.apache.cordova.inappbrowser/>
< gap:plugin name =org.apache.cordova.media/>
< gap:plugin name =org.apache.cordova.network-information/>
< gap:plugin name =org.apache.cordova.splashscreen/>
< gap:plugin name =org.apache.cordova.vibration/>

并移除了< preference name =permissionsvalue =none /> permission config



5)创建了一个名为dirReader.js的外部js文件, in app.json



dirReader.js内容

  window.onerror = function(msg,url,linenumber){
alert('错误信息:'+ msg +'\\\
URL:'+ url +'\\\
Line Number:'+ linenumber)
return true
}

var dirList = [{name:'Chart 1'},{name:'Chart 2'}];
//等待设备API库加载
//
document.addEventListener(deviceready,onDeviceReady,false);

//设备API可用
//
function onDeviceReady(){
alert(device ready);
Ext.device.FileSystem.requestFileSystem(
LocalFileSystem.PERSISTENT,0,function(fs){// LocalFileSystem未定义错误在这里
alert(Root =+ fs.root.fullPath );
var directoryReader = fs.root.createReader();
directoryReader.readEntries(function(entries){
var i;
for(i = 0; i< entries .length; i ++){
//alert(entries[i].name);
var itemObj = {};
itemObj.name = entries [i] .name;
dirList.push(itemObj);
}
var dirListString = JSON.stringify(dirList);
alert(dirListString);
},function(error){
alert(error.code);
})
},function(error){
alert(error.code);
});
}

6) 'ext.device.FileSystem' in app.js



7) c> sencha app build native
这会导致在命令提示符(无错误)中发生许多mumbo jumbo。该应用程序被压缩并上传到build.phonegap for android构建。建立成功。



----------------------------- -------------------------------------------------- ---------



PROBLEM >该应用安装并开始正常。
我从dirReader.js文件接收到设备就绪警报。
我得到的下一个错误是 LocalFileSystem未定义在dirReader.js。





我检查了构建的apk包含了所有插件的plugins文件夹,包括 org.apache.cordova.file 。此外,cordova_plugins.js存在,并且具有 window.LocalFileSystem 条目。

解决方案

我看到了同样的问题.. cordova_plugin.js包含

  {
file :plugins / org.apache.cordova.core.file / www / FileSystem.js,
id:org.apache.cordova.core.file.FileSystem,
clobbers :[
window.FileSystem
]
},

您是否尝试使用> cordova build构建android



您可以调用任何其他API方法吗?


I followed these sencha cmd guide to produce a phoneGap based sencha touch 2 project: Using Latest Sencha Cmd v4.0.2.67 , Latest sencha touch 2.3.1 , phoneGap ver- 3.1.0

1) Make a sencha touch 2 project by :

sencha -sdk /path/to/sencha-touch-sdk generate app MyApp /path/to/www/myapp

2) Add phoneGap to the above project

sencha phonegap init

3) configure the phonegap.local.properties

phonegap.platform=android
phonegap.build.remote=true
phonegap.build.remote.username=myUseName
phonegap.build.remote.password=myPassword

4) Updated the config.xml by adding all the core plugins

<!-- Core plugins -->
    <gap:plugin name="org.apache.cordova.battery-status" />
    <gap:plugin name="org.apache.cordova.camera" />
    <gap:plugin name="org.apache.cordova.media-capture" />
    <gap:plugin name="org.apache.cordova.console" />
    <gap:plugin name="org.apache.cordova.contacts" />
    <gap:plugin name="org.apache.cordova.device" />
    <gap:plugin name="org.apache.cordova.device-motion" />
    <gap:plugin name="org.apache.cordova.device-orientation" />
    <gap:plugin name="org.apache.cordova.dialogs" />
    <gap:plugin name="org.apache.cordova.file" />
    <gap:plugin name="org.apache.cordova.file-transfer" />
    <gap:plugin name="org.apache.cordova.geolocation" />
    <gap:plugin name="org.apache.cordova.globalization" />
    <gap:plugin name="org.apache.cordova.inappbrowser" />
    <gap:plugin name="org.apache.cordova.media" />
    <gap:plugin name="org.apache.cordova.network-information" />
    <gap:plugin name="org.apache.cordova.splashscreen" />
    <gap:plugin name="org.apache.cordova.vibration" />

and removed the <preference name="permissions" value="none"/> permission config

5) Created a external js file named dirReader.js and included its path in app.json

dirReader.js Contents

window.onerror=function(msg, url, linenumber){
     alert('Error message: '+msg+'\nURL: '+url+'\nLine Number: '+linenumber)
     return true
    }

var dirList = [{name: 'Chart 1'},{name: 'Chart 2'}];
 // Wait for device API libraries to load
    //
    document.addEventListener("deviceready", onDeviceReady, false);

    // device APIs are available
    //
    function onDeviceReady() {
        alert("device ready");
            Ext.device.FileSystem.requestFileSystem(
                LocalFileSystem.PERSISTENT, 0, function(fs) {   // LocalFileSystem not defined error here
                alert("Root = " + fs.root.fullPath);
                var directoryReader = fs.root.createReader();
                directoryReader.readEntries(function(entries) {
                var i;
                for (i=0; i<entries.length; i++) {
                    //alert(entries[i].name);
                    var itemObj = {};
                        itemObj.name = entries[i].name;
                    dirList.push(itemObj);
                }
                var dirListString = JSON.stringify(dirList);
                alert(dirListString);
                }, function (error) {
                alert(error.code);
                })
                }, function (error) {
                alert(error.code);
            });
    }

6) Added 'Ext.device.FileSystem' in requires under app.js

7) Finally ran sencha app build native This causes many mumbo jumbo to take place in the command prompt (No Errors) . the app is compressed and uploaded to build.phonegap for android build. Build succeeds.

----------------------------------------------------------------------------------------

PROBLEM

The app installs and starts fine. I receive the "Device Ready" alert from the dirReader.js file. The next error I get is that LocalFileSystem is undefined in dirReader.js.

I tried lots of things but nothing works.

I checked that the built apk contains the plugins folder with all the plugins including the org.apache.cordova.file . Also , the cordova_plugins.js is present and has the window.LocalFileSystem entry.

解决方案

I saw somewhere the same issue.. is the cordova_plugin.js contain

{
    "file": "plugins/org.apache.cordova.core.file/www/FileSystem.js",
    "id": "org.apache.cordova.core.file.FileSystem",
    "clobbers": [
        "window.FileSystem"
    ]
},

did you try build with >cordova build android

can you call to any other API method?

这篇关于sencha touch与phonegap(使用sencha cmd和phonegap构建)导致错误:LocalFileSystem未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆