Question

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
Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top