device is not defined

1,539 views
Skip to first unread message

Stefano Musaico

unread,
Jan 23, 2014, 11:25:11 AM1/23/14
to phon...@googlegroups.com
I'm newbie and I have some problems with cordova 3.3.0.
I have to use device.version in my app but I have this error: "device is not defined". I have imported correctly cordova.js.
It worked fine with phonegap 2.9.0 that I used.
What can I do?

Thanks in advance
Stefano

Kelvin

unread,
Jan 23, 2014, 12:16:01 PM1/23/14
to phon...@googlegroups.com
Have you added the device plugin?

`cordova plugin add org.apache.cordova.device`

Stefano Musaico

unread,
Jan 24, 2014, 6:20:57 AM1/24/14
to phon...@googlegroups.com
I have added in config.xml file this code:
 <feature name="Device">
      <param name="android-package" value="org.apache.cordova.Device"/>
    </feature>

is there something else to add?

thanks

Lorin Beer

unread,
Jan 24, 2014, 6:28:19 PM1/24/14
to phon...@googlegroups.com
Hi Stefano,

You shouldn't have to manually add anything to config.xml. Either start a new project or remove the entry in config.xml and add the device plugin from the cli

$ phonegap plugin add org.apache.cordova.Device


- Lorin

Stefano Musaico

unread,
Jan 26, 2014, 12:35:24 PM1/26/14
to phon...@googlegroups.com
Hi,
I was wrong, really I didn't add anything to config.xml because the Device feature was already there when I created the project. 
Nevertheless I don't understand in which folder in command line I have to launch this function "phonegap plugin add org.apache.cordova.Device"
..I use windows and the function "phonegap" is not recognized.

thanks
Stefano

Kelvin

unread,
Jan 27, 2014, 3:53:35 AM1/27/14
to phon...@googlegroups.com
How about `cordova plugin add org.apache.cordova.device`? Do this in the root of your cordova project (i.e. where you'll find merges, platform, plugins, and www).

Stefano Musaico

unread,
Jan 27, 2014, 1:05:46 PM1/27/14
to phon...@googlegroups.com
Hi,
I succeeded in creating new project using command line. I created my old project using function create into "..\cordova-3.3.0\cordova-android\bin" folder. I don't understand why these projects are different (in the old project there aren't merges, platforms and plugin folders).
However I installed device plugin in this new project but I have still the same error "device is not defined".

thanks for your helps.

Kelvin

unread,
Jan 29, 2014, 11:15:44 AM1/29/14
to phon...@googlegroups.com
Hmm by old project, do you mean pre-version 3.x? If so, then in Cordova 2.x onwards, there was the addition of a 'create' script which would build a default project for you where you can edit it. But you had to download that script with each new version of Cordova.

As of Cordova 3.x, they started distributing Phonegap via npm using node.js. Which integrated deeper into the operating system but meant it was readily available more easily. As a result, you can do `phonegap create` wherever in your directory structure.

So to verify, can you confirm what happens when you do the following please:
  1. phonegap -v
  2. phonegap create Test
  3. cd Test
  4. phonegap plugin add org.apache.cordova.device
  5. phonegap platform add [ios|android|wp8]
  6. phonegap build
This should get a simple project up and running. You'll then need to import this into Eclipse (open Eclipse and go to File > Import existing code into workspace then navigate to your phonegap directory and look for platforms/[your-platform].

BTW if you're using Cordova and Phonegap (which is what I also do), then replace every Phonegap instance in my answer above, with Cordova (lower-case in the CLI).

Maycow F

unread,
Jun 10, 2014, 2:36:28 PM6/10/14
to phon...@googlegroups.com
In my Galaxy, I installed Samsung USB Driver and Google USB Driver and my device appears on "adb devices"
Reply all
Reply to author
Forward
0 new messages