Cordova 3.3.1-0.1.2 (Phonegap) plugins doesn't work

I have a cordova 3.3.1-0.1.2 test project for iOS, where I use the following plugins (cordova plugin ls):

[ 'com.phonegap.plugins.PushPlugin',
  'org.apache.cordova.splashscreen' ]

I’ve added the plugins like this cordova plugin add org.apache.cordova.device. In my git repo, I see, that it adds a bunch of files to the plugins/org.apache.cordova.device directory, creates a CDVDevice.h and a CDVDevice.m in my iOS plugin directory, updates the ios.json, updates the *.xcodeproj file and adds the plugins to my config.xml inside platforms/ios/test-app/config.xml:

<feature name="Device">
    <param name="ios-package" value="CDVDevice" />

But when I try to access the device or window.device property inside JS, it tells me, that device is undefined. The weird thing is, that the pushPlugin is present:

document.addEventListener("deviceready", function () {

The window.plugins object only lists the pushNotification plugin as a property. It’s weird, because they are all installed, and during the installation, cordova said, everything was ok.

I’m a little bit confused, about the outdated, and mixed-with-phonegap documentation, but that would be ok, if one of them would work. I also saw a plugin definition, inside a config.xml like this

<gap:plugin name="org.apache.cordova.device" />

Can someone explain me, what’s the difference? Is the way (with feature) that I’m working outdated with cordova 3.3? When I try to use the <gap:plugin... format, my app crashes on startup.

So, please help me to fix this, and clear my mind 😉

  • Is ClearCase supported in Visual Studio 2010
  • Can Hudson check out from multiple SCMs?
  • Cordova - Install AdMob Plugin on Android Failed (Mac)
  • Jenkins plugin - environement variables
  • Jenkins with JSLint and Violations plugin
  • Repo plugin for TeamCIty?
  • Does Visual Studio 2010 express prevents Source Controls plugins?
  • How to version control overlapping folder structures?
  • 4 Solutions collect form web for “Cordova 3.3.1-0.1.2 (Phonegap) plugins doesn't work”

    Unfortunately, none of the answers worked. Luckily, I found the solution in this mailing list:

    There they say, that this is a bug in cordova 3.3.1. In this versions, the plugins get copied into the .staging directory of the different platforms.

    So, downgrading with npm to cordova 3.3.0 now worked (on Mac OS X):

    sudo npm remove -g cordova
    sudo npm view cordova versions
    sudo npm install -g cordova@3.3.0-rc.1

    And also check, if cordova is maybe installed from phonegap too. If you only use cordova, and non of the phonegap features (like remote build), you can safely remove the phonegap package with

    sudo npm remove -g phonegap


    The current version 3.4.0 works fine, and doesn’t have this issues.

    plugin definition using gap:plugin is for configuring plugins for phonegap build (so you don’t need it for local build).

    As MBillau suggested, the plugins are added to the platform only after you run cordova prepare ios (or cordova build ios which launches prepare and then builds the project).

    When you run prepare, javascript files of the plugin should be copied to the www/plugins/pluginfullname/www folder of the platforms/ios folder.

    If the files are not there it may be an issue with the ios.json file being corrupted. In that case, sometimes uninstalling and then re-installing the plugin solves the problem. In some case you have to remove the ios.json file, and empty the plugins folder at the root of your project (and maybe allso the platforms folder) and re-install all the plugins.

    If window.plugins object only lists the pushnotification plugin it is just because it is the only plugin installed in this object :

    • org.apache.cordova.console is in console and cordova.logger
    • org.apache.cordova.device is in window.device
    • org.apache.cordova.splashscreen is in navigator.splashscreen

    To know javascript object name to use, you have to read the plugin’s documentation or look at the js-module/clobbers property in the plugin.xml file of the plugin.

    From the root of your Cordova project, go into ./platforms/ios/

    cd platforms/ios

    In here there should be a ./build folder – this contains previously built packages which Cordova then uses for ‘lazy loading’ – i.e. so Cordova does not constantly have to fetch files from various locations, it stores them locally instead. However, I have found this to be problematic.

    Delete this folder:

    sudo rm -r build

    When gone, rebuild your Cordova project:

    cordova build

    It should then recreate the build folder but more importantly, your plugins will be listed in config.xml.

    Check you index.html file has the correct <script></script> lines.

    I had an issue when creating a new project via CLI. The index.html file referenced phonegap.js instead of cordova.js

    Git Baby is a git and github fan, let's start git clone.