Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-13637

Unable to handle local plugins properly



    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • cordova-lib
    • None


      1) create a new cordova project

      2) inside the project directory, create folder "localplugins/testplugin" containing the file:

      • package.json
        	"name": "com.example.cordova.plugin",
        	"version": "1.0.0"
      • plugin.xml
        <?xml version="1.0" encoding="UTF-8"?>
        <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="com.example.cordova.plugin" version="1.0.0">
            <name>Test Plugin</name>
            <platform name="android">
                <config-file target="AndroidManifest.xml" parent="/*">
                    <uses-permission android:name="android.permission.WAKE_LOCK" />

      3) add android patform: cordova platform add android

      4) prepare android: cordova prepare android

      At this point, both package.json and config.xml contain a reference to the plugin using "file:localplugins/testplugin". The problem is that it's impossible to use the same plugin reference in both files, and still having plugin restoration and/or "npm install" to work.

      If I delete platforms/ and plugins/ subdir (these are typically not under git revision control) and run "cordova prepare android" to restore the platforms and the plugins, it fails with error:

      Discovered plugin "com.example.cordova.plugin" in config.xml. Adding it to the project
      Failed to restore plugin "com.example.cordova.plugin" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin file:localplugins/testplugin via registry.
      Probably this is either a connection problem, or plugin spec is incorrect.
      Check your connection and plugin name/version/URL.
      Failed to get absolute path to installed module

      If I edit package.json and config.xml, and remove the prefix "file:" in the plugin spec, then restoration works ok. But then, it's "npm install" that fails.

      What works is to use the "file:" prefix in package.json and not use it in "config.xml". But that's not possible as preparation will make sure both are identical.


        Issue Links



              Unassigned Unassigned
              goffioul Michael Goffioul
              1 Vote for this issue
              2 Start watching this issue