Phone Gap 'ReferenceError: Can't find variable: device'
I am very new to PhoneGap yet have not been able to get some sample code to run properly. I believe I have went through the entire setup process properly, but perhaps I am missing something.
I get the following error.
file:///android_asset/www/js/pg.js Line: 107: ReferenceError: Can't find variable device
Here is the javascript which produces the error.
var info = [
{ name : 'Device Name', value : device.name },
{ name : 'Device PhoneGap', value : device.phonegap },
{ name : 'Device Platform', value : device.platform },
{ name : 'Device UUID', value : device.uuid },
{ name : 'Device Version', value : device.version }
];
The above should not be executed until the DOM i开发者_如何转开发s ready, so all scripts are loaded properly before this is executed.
This code works fine with an IPhone Simulator and XCode, however it fails with Android Emulator on Eclipse. The droidgap javascript is included before this script and I have made sure that it is loading. My guess is the real problem is somewhere on the Java side of things, but I cannot pinpoint it. I'm not sure what other details I can include. If you have any questions I will try to reply promptly. I'm welcoming any suggestions at this point.
EDIT: This line of code also fails inside the onDeviceReady function
navigator.notification.alert("Device Ready.");
I was using Iphone phonegap javascript instead of the Android javascript, causing nothing to work.
精彩评论