Sunil Kumar
Sunil Kumar

Reputation: 7082

How to add our own made plugin in cordova 3.1 project though Cordova CLI for android platform?

I am able to add the plugin which is designed by Apache though cordova command line interface for android platform. But I could not able to add the plugin which are designed by own though the CLI. please help me sort out to add plugins which is made by own in cordova3.1 project.

Upvotes: 0

Views: 783

Answers (2)

Sunil Kumar
Sunil Kumar

Reputation: 7082

After a lot of struggle I found the solution for the above problem.

  1. Create Cordova Project(suppose CordovaDemo) through CLI
  2. Add the platform android
  3. Add the your own plugin your.js file inside the js of CordovaDemo/www/js/your.js
  4. Edit the CordovaDemo/www/index.html Add below script tag

    < script type="text/javascript" src="js/your.js">

  5. Add your YourPlugin.java file inside the src of your android platform

6.Add this inside res/xml/config.xml

 < feature name="YourPlugin">

           < param name="android-package" value="yourpackage.YourPlugin" />

       < /feature>

Import android project in eclipse and run

Upvotes: 1

mooreds
mooreds

Reputation: 4978

If you create a plugin.xml file in your custom plugin directory (read this doc on how to do this: http://cordova.apache.org/docs/en/3.1.0/plugin_ref_spec.md ), you should be able to either:

  • put the plugin up on a git repository somewhere (I've only used github, but any git repo should work: cordova plugin add http://github.com/youraccount/yourrepo/
  • put the plugin somewhere on a filesystem: cordova plugin add relative/path/to/dir/containing/plugin.xml or cordova plugin add /absolution/path/to/dir/containing/plugin.xml

Using the plugin.xml lets you leverage the automatic injection of xml into the config.xml, etc.

Upvotes: 1

Related Questions