我按照这些sencha cmd指南制作了一个基于phoneGap的sencha touch 2项目: 使用最新的Sencha Cmd v4.0.2.67,最新的sencha touch 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)通过添加所有核心插件
更新了config.xml<!-- 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" />
并删除了<preference name="permissions" value="none"/>
权限配置
5)创建一个名为dirReader.js的外部js文件,并在app.json中包含其路径
dirReader.js内容
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)在app.js下的要求中添加了'Ext.device.FileSystem'
7)最后跑了sencha app build native
这会导致许多mumbo jumbo在命令提示符中发生(No Errors)。应用程序被压缩并上传到build.phonegap for android build。建立成功。
-------------------------------------------- --------------------------------------------
问题
该应用程序安装并正常启动。
我从dirReader.js文件收到“设备就绪”警报。
我得到的下一个错误是dirReader.js中的LocalFileSystem is undefined
。
我尝试了很多东西,但没有任何作用。
我检查了构建的apk包含插件文件夹,其中包含所有插件,包括org.apache.cordova.file
。此外,cordova_plugins.js存在且具有window.LocalFileSystem
条目。
答案 0 :(得分:2)
我看到同样的问题..是cordova_plugin.js包含
{
"file": "plugins/org.apache.cordova.core.file/www/FileSystem.js",
"id": "org.apache.cordova.core.file.FileSystem",
"clobbers": [
"window.FileSystem"
]
},
您是否尝试使用&gt; cordova build android
进行构建你可以调用任何其他API方法吗?