I'm using Cordova 3.0. I'm able to create a skeleton project and run it without any problem. Now I want to add the Device plugin. Here are my steps:
1. Added assets\www\device.js
2. Modified res\xml\config.xml and added:
<feature name="Device">
<param name="android-package" value="org.apache.cordova.Device" />
</feature>
- Modified AndroidManifest.xml and added:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Added src\Device.java
In index.html I added script src:
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="device.js"></script>
<script type="text/javascript" src="js/index.js"></script>
In the index.js I added the following code:
onDeviceReady: function() {
app.receivedEvent('deviceready');
console.log('device.model=>' + device.model);
},
I build and run on the android emulator and get the error:
10-03 12:22:49.998: E/Web Console(637): Uncaught ReferenceError: require is not defined at file:///android_asset/www/device.js:22
10-03 12:22:50.489: I/Web Console(637): device.model=>undefined at file:///android_asset/www/js/index.js:40
Any ideas on what im missing? I've followed the instructions at the phonegap site http://docs.phonegap.com/en/edge/cordova_device_device.md.html#Device