鼓掌& Android 上的 Phonegap

发布于 2024-12-28 18:46:46 字数 1234 浏览 1 评论 0原文

我的问题是关于使用 Eclipse Applaud 插件进行 PhoneGap 和 Android 开发。我成功下载并安装了Applaud插件。我可以使用 Applaud 向导(通过 Eclipse 工具栏图标)创建一个新项目,并且演示可以在设备上正常运行。但是,当我覆盖现有的 html & js(仅 main.js,而不是phonegap.js)文件,然后将其构建到设备上,非设备功能工作正常(按钮单击/ui 更新/等),但 PhoneGap 命令例如(device.version/device.js)平台/等)似乎不起作用。

我尝试将其挂接到 onDeviceReady 事件中,并确保包含 .jar 库,但我仍然遇到同样的问题。所以我想我的问题是;使用Applaud创建PhoneGap解决方案时,Eclipse是否需要编译和库,例如PhoneGap?如果是这样,怎么会有人去做这样的事情呢?

错误日志:

01-24 14:59:44.567: W/KeyCharacterMap(5453): No keyboard for id 131074

01-24 14:59:44.567: W/KeyCharacterMap(5453): Using default keymap: /system/usr/keychars/qwerty.kcm.bin

01-24 14:59:59.917: I/Web Console(5453): Failed to run constructor: TypeError: object is not a function at file:///android_asset/www/resources/js/phonegap-1.3.0.js:210

01-24 14:59:59.927: I/Web Console(5453): Failed to run constructor: TypeError: Cannot read property 'capture' of undefined at file:///android_asset/www/resources/js/phonegap-1.3.0.js:210

01-24 14:59:59.927: I/Database(5453): sqlite returned: error code = 14, msg = cannot open file at source line 25467

01-24 15:00:00.057: D/dalvikvm(5453): GC_CONCURRENT freed 1185K, 55% free 3188K/6983K, external 2630K/2814K, paused 2ms+3ms

My issue is regarding PhoneGap and Android development using the Eclipse Applaud plugin. I downloaded and installed the Applaud plugin successfully. I can create a new project using the Applaud wizard (via the Eclipse toolbar icon), and the demo runs on the device fine. However, when I overwrite the existing html & js (only main.js, not phonegap.js) files, then build it to the device, the non device functionality works fine (button clicks/ui update/etc), but the PhoneGap commands such as (device.version/device.platform/etc) does not seem to work.

I have tried hooking this into the onDeviceReady event as well as making sure the .jar library is included, but I still have the same issue. So I guess my question is; when creating a PhoneGap solution using Applaud, does Eclipse need to compile and library, such as PhoneGap? and if so, how could someone go about doing such things?

Error Log:

01-24 14:59:44.567: W/KeyCharacterMap(5453): No keyboard for id 131074

01-24 14:59:44.567: W/KeyCharacterMap(5453): Using default keymap: /system/usr/keychars/qwerty.kcm.bin

01-24 14:59:59.917: I/Web Console(5453): Failed to run constructor: TypeError: object is not a function at file:///android_asset/www/resources/js/phonegap-1.3.0.js:210

01-24 14:59:59.927: I/Web Console(5453): Failed to run constructor: TypeError: Cannot read property 'capture' of undefined at file:///android_asset/www/resources/js/phonegap-1.3.0.js:210

01-24 14:59:59.927: I/Database(5453): sqlite returned: error code = 14, msg = cannot open file at source line 25467

01-24 15:00:00.057: D/dalvikvm(5453): GC_CONCURRENT freed 1185K, 55% free 3188K/6983K, external 2630K/2814K, paused 2ms+3ms

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

画▽骨i 2025-01-04 18:46:46

所以我回来了并以某种方式解决了我遇到的问题(很可能是幸运的)。当我开始这个项目时,我认为最好的方法是使这个应用程序尽可能模块化;每个功能(Web 请求、文件读/写等)要相互分离。因此,我创建了许多单独的 js 文件,每个文件都标有适当的名称(网络、设备、语言等),然后将它们包含在我的 index.html 页面中,然后由phonegap 运行该页面。

在其中一些文件中,我采用了以下方法:

var Device = {
    // Returns the Device Name as a string.
    Name: function() {
        return window.device.name;
    }
};

因此,我可以使用点运算符(我更喜欢)访问此功能。然而,这样做会导致许多文件相互依赖,从而很难追踪我的问题。在花了一些时间注释和取消注释功能之后,似乎是通过使用上述方法(点运算符)和我对命名约定的错误选择的组合。上面的 Device.Name() 实现似乎(不完全确定原因/方式)与 PhoneGap 库冲突,从而导致设备上出现 js 错误。

将上述名称从“设备”更改为“手机”后,我的问题消失了。对于一个痛苦的下午来说,这是一个简单且可能显而易见的解决方案。

So I'm back and have somehow fixed the issue I had (most likely by luck). When I started this project, I thought the best approach would be make this application as modular as possible; each functionality (web requests, file reading/writing, etc.) to be separated from one another. Thus I created lots of separate js files, each tagged with the appropriate name (network, device, language, etc.), and then included them in my index.html page which is then ran by phonegap.

In some of these files, I took the following approach:

var Device = {
    // Returns the Device Name as a string.
    Name: function() {
        return window.device.name;
    }
};

As a result, I could then access this functionality using the dot operator (which I prefer). However by doing so, resulted in many files relying one on another, making it difficult to track down my issue. After spending some time commenting and un-commenting functionality, It seems by using a combination of the above approach (dot operator) and my bad choice of naming conventions. The Device.Name() implementation above seemed to (not entirely certain on why/how) conflict with the PhoneGap libraries, consequently resulting in js errors on the device.

After changing the above name from "Device" to "Handset", my issue went away. A simple and maybe obvious solution to a painful afternoon.

唯憾梦倾城 2025-01-04 18:46:46

我会回答您的问题,但我不认为这是您的问题:

AppLaud 向导是否只使用phonegap.jar 还是重建其组件取决于您如何使用项目创建向导。

如果您使用其“内置 Phonegap”或指向下载的官方版本(“输入已安装 PhoneGap 的路径”),它将仅指向该版本中的phonegap.jar。如果您指向具有解压的 github PhoneGap 版本的目录,则不会使用phonegap.jar,并且 PhoneGap Java 源代码将内置到您的项目中。这使得 PhoneGap 实现的调试变得容易。

关于您的问题,您的index.html 文件可能有问题,例如phonegap{...}.js 的拼写错误。正如 GhostCoder 在评论中所说,您可能需要分享您的代码才能获得帮助。

I'll answer your question, but I don't think it is your problem:

Whether or not the AppLaud wizard just uses phonegap.jar or rebuilds its components depends upon how you use the project creation wizard.

If you use its "Built-in Phonegap" or point at a downloaded official release ("Enter path to installed PhoneGap"), it will just point at the phonegap.jar from that release. If you point at a directory with an unzipped github PhoneGap version, phonegap.jar will not be used and the PhoneGap Java sources will be built into your project. This makes for easy debugging of the PhoneGap implementation.

Regarding your problem, you likely have something wrong with your index.html file, like a misspelling of phonegap{...}.js. As ghostCoder says in the comments, you may need to share your code to get help on it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文