Khusbu Mishra
Khusbu Mishra

Reputation: 181

Unable to add a cordova plugin from local folder

I am creating a sample app in Ionic. On adding a cordova plugin to my app from local folder I get below error:

cordova plugin add ../local-cordova-plugin --save
✖ Running command - failed!
[ERROR] An error occurred while running cordova plugin add ../local-cordova-plugin --save (exit code 1):
Error: Failed to get absolute path to installed module

Note: This error occurs if I add it after I have added plugins from npm repository or adding any platform to my app. If I add it first, before adding any other plugin or platform, it gets added successfully.

Steps to reproduce:

$ ionic cordova plugin add ../local-cordova-plugin

Note: Add the local cordova plugin after adding a platform or a plugin from npm repository to your ionic app.

Other information: There is a similar issue posted but it didn't resolve my issue. I have used flags like --nofetch, --force, --noregistry, --searchpath but of no help.

Ionic info:

``` cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

global packages:

Cordova CLI : 7.0.1 

local packages:

@ionic/app-scripts : 2.1.3
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.6.0

System:

Android SDK Tools : 26.0.2
Node              : v7.0.0
npm               : 3.10.8 
OS                : macOS Sierra

Update: plugin.xml of my local-cordova-plugin (as requested by @MaximShoustin)

<?xml version='1.0' encoding='utf-8'?>
<plugin id="com.local.cordova" version="0.0.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
  <name>local_plugin</name>
  <js-module name="local_plugin" src="www/local_plugin.js">
    <clobbers target="local" />
  </js-module>
  <platform name="android">
    <config-file parent="/*" target="res/xml/config.xml">
      <feature name="local_plugin">
        <param name="android-package" value="com.local.cordova.local_plugin" />
      </feature>
    </config-file>
        <config-file parent="/*" target="AndroidManifest.xml">
    </config-file>
    <source-file src="src/android/local_plugin.java" target-dir="src/com/local/cordova/local_plugin" />
    <resource-file src="local-release/local-1.0.0-release.aar" target="libs/local-1.0.0-release.aar" />
    <edit-config file="AndroidManifest.xml" target="/manifest/uses-sdk" mode="merge">
        <uses-sdk android:minSdkVersion="19" />
    </edit-config>
  </platform>
</plugin>

Upvotes: 2

Views: 5752

Answers (2)

Kidoncio
Kidoncio

Reputation: 149

You should run with ionic cordova plugin add /path/to/your/plugin --link

You can know more from that here.

Upvotes: 0

Khusbu Mishra
Khusbu Mishra

Reputation: 181

After a lot of searching and surfing, I got the solution to my problem. I looked into node_modules and there is a file/symlink of the plugin I wanted to install. Once I removed that, I had no problem installing the plugin.

Upvotes: 2

Related Questions