Faical.sakhi 240293fa
Faical.sakhi 240293fa

Reputation: 11

CordovaError: Invalid Plugin! ..\hello needs a valid package.json

I am trying to develop a custom plugin in Cordova. Problem is that Cordova does not recognize the JSON file. Click here to see image

my json file:

{
  "name": "hello",
  "version": "0.1.1",
  "description": "show hello cordova",
  "cordova": {
    "id": "cordova-plugin-hello",
    "platforms": []
  },
  "keywords": [
    "ecosystem:cordova"
  ],
  "author": "shubham",
  "license": "ISC"
}

my plugin.xml

<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-hello" version="0.1.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android"><name>hello</name><js-module name="hello" src="www/hello.js"><clobbers target="cordova.plugins" /></js-module>

Thank you for your help and for your time.

Upvotes: 1

Views: 1548

Answers (1)

Ronit Roy
Ronit Roy

Reputation: 960

For adding a custom Cordova plugin, you can use Plugman.

You can Install Plugman globally using the command

npm install -g plugman

Then Navigate to the folder where you want to create your plugin.

Create the initial code of our plugin using the following command

plugman create --name YourPluginName --plugin_id cordova-plugin-YourPluginName --plugin_version 0.0.1 

Add Android platform to the plugin using command

plugman platform add --platform_name android

Now, for creating package.json file in your current directory, in the plugin based on values from plugin.xml, use the command

plugman createpackagejson -- or npm init

Now for installing the plugin in our existing Cordova project for Android using command

plugman install --platform android --project platforms/android --plugin ../YourPluginName/

reference visit here.

Upvotes: 5

Related Questions