android – PhoneGap 3 plugin: exec() call to unknown plugin "…"-ThrowExceptions

Exception or error:

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

How to solve:

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

###

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).

###

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).

###

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.

###

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.

Leave a Reply

Your email address will not be published. Required fields are marked *