Search code examples
cordovacordova-plugins

What is the right way to manage and install Cordova plugins when using Crosswalk?


I'm using Crosswalk (cordova-plugin-crosswalk-webview) in my Cordova project and I'm bit confused because Crosswalk affects plugins, Cordova 5 switched to NPM for plugins, and the naming of plugins has changed. It seems documentation has not been updated/unified everywhere yet.

Anyway,

This works:
<plugin name="org.apache.cordova.camera" version="0.3.6" />

This also works:
<plugin name="https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git#1.0.0" />

This does not work:
<plugin name="cordova-plugin-camera" version="1" /> (gives me a build error on Android)

Three questions about that:

  1. What's the difference between these plugins?
  2. Which plugin configuration is the best to use for Cordova >= 5?
  3. Are these plugins maintained by the same organization?

Solution

  • The difference between the plugins is none other that the source of the plugin installation. Both were installed either with the cordova CLI or plugman with one of the following commands

    cordova plugin install
    plugman install --platform [platform] --project . \ --plugin [plugin_name]
    

    In your first case

    <plugin name="org.apache.cordova.camera" version="0.3.6" />
    

    was installed using any of the above but with a syntax like this

    cordova plugin install org.apache.cordova.camera 
    

    This might not work correctly if you are using an older version of cordova because they moved the plugin repository to npm so you can use the next alternative

    <plugin name="https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git#1.0.0" />
    

    was installed using git directly from the github repository

    cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git
    

    It's basically the same, the second being more flexible since it let you install plugins not registered in the cordova plugin registry so you can test your own plugins.

    As for your second question "Which plugin configuration is the best to use for Cordova >= 5" there is a catch here. You are using crosswalk, this means that you must use the plugin compatibility table listed here. This is probably why you are getting a compilation error on android, wrong plugin version.

    If you were not using crosswalk always use the last version of the plugin. Cordova is making a lot of changes lately so this will keep you up to date.

    As for the last question you usually can lookup the plugin name for the author. Cordova is an Apache project so all plugin starting with org.apache.cordova prefix are the official cordova plugins. This doesn't mean that they are better that others, just that they are created by the same team that develop cordova itself which gives you a certain degree of trust but is normal that any plugin have bugs, they are programs after all :)

    You can look for more information on the plugin registry site. This will also give you information like who are the people maintaining the plugin, documentation, it's github repository and it's issue tracker to report bugs. Plugins usually contain a README file with relevant information about the author and website that that you can use also.