Device plugin window.device is undefined

  • 1
  • Question
  • Updated 7 years ago
  • Answered
Hi,

I'm working in cordova/phonegap and have added the "Device" plugin. I see everything I should see in my config.xml (I don't think I need anything in www/config.xml), but there's no way for me to access device or window.device or anything anywhere in my app (I'm checking after deviceready, for what that's worth)

If anyone has any info that they could help me with it would be greatly appreciated!

Thank you,

--d
Photo of Luke DeWitt

Luke DeWitt

  • 4 Posts
  • 0 Reply Likes

Posted 7 years ago

  • 1
Photo of Amir

Amir

  • 8261 Posts
  • 263 Reply Likes
Hi D

Can you share your Build appid? It can be found at the URL bar (http://build.phonegap.com/apps/#####)

Thanks
Photo of Alan Neveu

Alan Neveu, Champion

  • 213 Posts
  • 11 Reply Likes
I am having the same problem Amir. My Build appid is:

http://build.phonegap.com/apps/213544

Help!
Photo of Jesse

Jesse, iOS Developer

  • 4 Posts
  • 0 Reply Likes
as of 3.0 the window.device is a plugin, presumably this affects phonegap build projects as well.

https://github.com/apache/cordova-plu...
Photo of Alan Neveu

Alan Neveu, Champion

  • 213 Posts
  • 11 Reply Likes
Turns out you have to set up your Config.xml like this:

<feature name="http://api.phonegap.com/1.0/camera"/>
<feature name="http://api.phonegap.com/1.0/file"/>
<feature name="http://api.phonegap.com/1.0/network"/>
<feature name="http://api.phonegap.com/1.0/notificat...>
<feature name="http://api.phonegap.com/1.0/device"/>

<gap:plugin name="org.apache.cordova.device"/>
<gap:plugin name="org.apache.cordova.camera"/>
<gap:plugin name="org.apache.cordova.device-orientation"/>
<gap:plugin name="org.apache.cordova.file"/>
<gap:plugin name="org.apache.cordova.globalization"/>
<gap:plugin name="org.apache.cordova.inappbrowser"/>
<gap:plugin name="org.apache.cordova.network-information"/>
<gap:plugin name="org.apache.cordova.dialogs"/>
<gap:plugin name="org.apache.cordova.splashscreen"/>

So the feature nodes are necessary at the device/install level, and the gap:plugin nodes are necessary for PGBuild to include the necessary plugins when compiling the app. It seems like you want to have parity between these two lists, even though for me it winds up being 5 features with 9 plugins. This is working for me against PhoneGap 3.1. Hope that helps!
Photo of Amir

Amir

  • 8261 Posts
  • 263 Reply Likes
Hi Luke

Can you confirm the above solution works (by adding gap:plugins on config.xml)?
Photo of Zahir

Zahir

  • 3500 Posts
  • 40 Reply Likes
Assuming the problem is resolved, this issue is now closed.

Create a new issue if you have any other problem with PhoneGap Build.

Thanks

This conversation is no longer open for comments or replies.