Manually install Device plugin (and others) into cordova 3.0

后端 未结 4 1620
花落未央
花落未央 2020-12-28 23:59

Phonegap/Cordova 3.0 has moved into a modular design starting with version 3.0. For example, to call the device.version API, you need to include the Device plug

相关标签:
4条回答
  • 2020-12-29 00:46

    For Android we just need to create the plugin (Java class extending CordovaPlugin) and then add the item into config.xml (res/xml/..) you are done.

     <feature name="Calendar">
            <param name="android-package" value="com.package.Calendar" />
        </feature>
    

    assume Calendar as your plugin name Also make sure to add link to js file

    Thanks

    0 讨论(0)
  • 2020-12-29 00:50

    I ran into the same issue.

    In fact, the plugin system has not changed much.

    I added the date picker plugin for Android just now :

    • add classes (.m .h for iphone, .java for android)
    • add js files where you want
    • add link to js files in your index.html
    • edit config.xml (path depends on which OS you used) :

    Instead of adding plugins between plugins tags :

    <plugin name="DatePickerPlugin" value="com.phonegap.plugins.DatePickerPlugin"/>
    

    You will add a feature (what a revolution !) like this :

    <feature name="DatePickerPlugin" >
        <param name="android-package" value="com.phonegap.plugins.DatePickerPlugin"/>
    </feature>
    

    And that is it !

    If you are not sure about the OS syntax for param name, you can add a default cordova plugin using a command as this one :

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

    More info there : http://cordova.apache.org/docs/en/3.0.0/guide_cli_index.md.html#The%20Command-line%20Interface

    0 讨论(0)
  • 2020-12-29 00:53

    You can do it this way, download the plugin locally to your machine then run this code

    cordova plugin add <id located in plugin.xml> --searchpath <local path to plugin>
    

    This will install the plugin into your project

    0 讨论(0)
  • 2020-12-29 01:00

    I was getting an error when I tried to add a plugin using the following command:

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

    Although, git clone was working, so I downloaded the plugin into a local folder and added it by using

    cordova plugin add my/local/folder
    
    0 讨论(0)
提交回复
热议问题