我一直在与这个斗争 . 我没有找到很多其他人遇到这个问题,而我找到的那些人没有安装File插件 .
在我的例子中,File插件是作为File-Transfer的依赖项安装的 .
Problem: 当我直接从我的PC构建并安装应用程序到我的Android设备时,一切正常,但是当它工作时 .
What happens: 在app.initialize()中,我调用cordova.file.applicationStorageDirectory:
var app = {
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener("deviceready", this.onDeviceReady, false);
},
onDeviceReady: function() {
initApp();
alert(1);
alert(cordova.file.applicationStorageDirectory);
alert(2);
}
};
当我在本地构建和安装时,会显示所有三个警报,并且目录路径是正确的,但是当它显示由PhoneGap Build alert(1);
构建时,但后两个调用不是 . 这让我相信cordova.file是未定义的 .
我尝试过使用PhoneGap Build的远程调试工具,但似乎没有任何东西在控制台中打印,尽管文档说它应该 .
以下是安装的插件:
这是我的config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "id-removed"
version = "0.0.0">
<preference name="phonegap-version" value="3.3.0" />
<name>Name removed</name>
<description>
Description removed.
</description>
<author email="email removed" href="removed">
Removed
</author>
<content src="index.html" />
<icon src="icon.png" />
<preference name="Orientation" value="portrait" />
<access origin="*" />
<gap:plugin name="org.apache.cordova.camera" version="0.2.9"/>
<gap:plugin name="org.apache.cordova.device-motion" version="0.2.6"/>
<gap:plugin name="org.apache.cordova.device-orientation" version="0.3.5"/>
<gap:plugin name="org.apache.cordova.file-transfer" version="0.4.2"/>
<gap:plugin name="org.apache.cordova.geolocation" version="0.3.7"/>
<gap:plugin name="org.apache.cordova.globalization" version="0.2.6"/>
<gap:plugin name="org.apache.cordova.inappbrowser" version="0.2.4"/>
<gap:plugin name="org.apache.cordova.network-information" version="0.2.7"/>
<gap:plugin name="de.appplant.cordova.plugin.local-notification" version="0.7.4"/>
</widget>
任何帮助表示赞赏 .
2 回答
好的,我只是在几个小时前了解我的眼睛:
In the official documentation,它说:
当您使用phonegap构建平台构建项目时, latest available version is 1.0.1
看那里:https://build.phonegap.com/plugins/617
这种情况,
cordova.file
将保持undefined
.Phonegap构建似乎遇到了一些升级插件的困难,甚至是核心插件 .
试试这个