19

I've been trying to upgrade a plugin to v3, and I've managed to get past the plugin loading issues, and I've managed to expose the plugin to the client environment (making changes to the way exec works, etc).

But when I watch the adb logcat with

adb logcat | grep -v nativeGetEnabledTags | grep -i web

I get this error:

D/PluginManager(11189): exec() call to unknown plugin: WebSocket

I can't work out what's gone wrong, and I'm not sure why the Android build can't see the plugin.

I've pushed ALL the code to a github repo, so if someone is able to replicate and help I'd be very welcome! I'm also trying to write up my experience of the conversion and logging the gotchas as I hit them (there's some in the readme, though it's incomplete):

Here's the repo: https://github.com/remy/phonegap_test

– Remy

Remy Sharp
  • 4,520
  • 3
  • 23
  • 40

5 Answers5

29

define your plugin in "res/xml/config.xml"

find these lines in the file

<feature name="App">
        <param name="android-package" value="org.apache.cordova.App" />
</feature>

and append these right after:

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

replace the dummy names (MyPluginName, plugins.plugin.class, etc) with the actual names. This works for me when I was getting this error:

exec() call to unknown plugin : MyPluginName

Sandeep Kumar
  • 1,193
  • 13
  • 14
  • 2
    Mine worked if the `name` attribute in `feature` is the same as the `value` attribute in `param`. So, `` – emen Sep 19 '13 at 08:27
  • Thaks, worked for me! But every time I run `cordova prepare android` its remove the entry for MyPlugin from res/xml/config.xml, and I need manually to update it before run the project. Would you know how to solve this? – alberjoe Apr 29 '15 at 17:35
  • What about a custom plugin in another package than phonegap ? I'm trying to load it in js using `cordova.require("cordova/plugin/MyPluginName");` but it is in different place in `src/`. The value I used is something like `com.mycompanyname.modulename.pugins.MyPluginName`. Is that correct ? – svassr Jun 03 '15 at 22:32
  • @AimanB You should add that as an answer - only thing that's worked for me! – dav_i Nov 11 '15 at 16:01
  • @alberjoe I've found a file in this path: `platforms\android\android.json` and I noticed that a record for my plugin is wrongly added to `app/src/main/res/xml/config.xml` (possibly because of different cordova version). I moved it to `res/xml/config.xml` along with other plugins and it fixed – Ehsan88 Oct 07 '18 at 18:50
  • @alberjoe Also I've found another trick that if you remove this `platforms\android\android.json` file, everything will be reset by the builder from plugin folder. – Ehsan88 Oct 07 '18 at 19:51
2

I am all of a sudden getting the same issue with my phone gap build (2.6). Same exact code worked prior so it must be a build issue.

Did you tried to open your apk and see if config.xml is included (there is where plugins are defined).

nurieta
  • 1,615
  • 15
  • 6
1

On Android Studio 1.0.1 (running on Mac OS 10.9.5) + Cordova 4.2.0, I fixed a similar problem ("exec() call to unknown plugin") as follow:

it happened that the content of the tag:

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

Under YourCordovaProjectName/config.xml was not duplicated under YourCordovaProjectName/platforms/android/res/xml/config.xml

I had to alter the file config.xml under YourCordovaProjectName/platforms/android/res/xml/ and to add the tag:

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

Then it worked.

I will also add that I've experienced the same problem with IOS, I had to enter manually:

<feature name="MyPluginName">
<param name="ios-package" value="com.phonegap.plugins.plugin.class" />
</feature>

In the file config.xml under the folder YourCordovaProjectName/platforms/ios/YourCordovaProjectName

Hopefully that will be fixed in the future and the content of YourCordovaProjectName/config.xml will correctly be reflected in the config.xml files that are under each specific platforms (it used to worked correctly for Android few months ago).

nyluje
  • 3,573
  • 7
  • 37
  • 67
1

For adding plugin definition in android under ProjectFolder/platforms/android/res/xml/config.xml,update the ProjectFolder/plugins/android.json

"cordova build” command will read this android.json file and update the ProjectFolder/platforms/android/res/xml/config.xml automatically with all plugins mentioned here.

Srihari
  • 11
  • 1
0

Are you getting a successful deviceready event? I have gotten that error in the past when my app was silently failing for other reasons in my code causing my deviceready event to never fire. In my case the silent error was due to some javascript syntax errors in my app.initialize() code blocks.

Christopher
  • 1,639
  • 19
  • 22