PhoneGap 3 plugin: exec() call to unknown plugin "..." - android

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

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.

Related

Call to Unknown Plugin Android

I am trying to write a plugin for my android phonegap application. I wrote the java class and the javascript items. When I was finished I took the java class file and added it to myEclipseProject/platforms/android/src/com/example/playSound/playSoundPlugin.java
I then opened up myEclipseProject/platforms/android/res/xml/config.xml and added the following lines
<Feature name="playSound">
<param name="android-package" value="com.example.playSound.playSoundPlugin" />
</Feature>
Whenever I try to call this plugin i get: Call to Unknown Plugin: playSoundPlugin
What am i missing? Please help. Thaks
Turns out I'm an idiot. tag should be all lower case!! hope this helps someone in the future.

Cordova Facebook Connect plugin fail on init

I installed the FacebookConnect plugin into my cordova project with the code:
cordova -d plugin add /Users/your/path/here/phonegap-facebook-plugin --variable APP_ID="123456789" --variable APP_NAME="myApplication"
Then linked the Facebook API (3.8.0) in /platforms/android/project.properties with:
android.library.reference.2=../../facebook-android-sdk-3.8.0/facebook
Then copied the example 'Simple' into the /www folder, added my app id and changed phonegap.js to cordova.js.
When I compile and run the application on my android phone I receive the following errors:
Cordova Facebook Connect plugin fail on init
Cordova Facebook Connect plugin fail on auth.status
and on login:
Cordova Facebook Connect plugin fail on login!Class not found
LogCat gives the following error:
exec() call to unknown plugin: org.apache.cordova.facebook.Connect
I've scoured the internet but cannot find a solution to this problem.
I did notice that my /platforms/android/res/xml/config.xml file lists the plugin as:
<feature name="FacebookConnectPlugin">
<param name="android-package" value="org.apache.cordova.facebook.ConnectPlugin" />
</feature>
When the Documentation says that it should be:
<feature name="org.apache.cordova.facebook.Connect">
<param name="ios-package" value="FacebookConnectPlugin" />
</feature>
But I can't change this as it's automatically generated during the compiling process.
Did you remember to copy (from the download) www/cdv-plugin-fb-connect.js, www/facebook-js-sdk.js into your apps www folder?
I got the same error, managed to fix by updating my root config.xml (which isn't generated) to include:
<feature name="org.apache.cordova.facebook.Connect">
<param name="android-package" value="org.apache.cordova.facebook.ConnectPlugin" />
</feature>
(Note android-package as looks like you are using android.)
This is under the manual install section of the readme, but also seems to be necessary after following the automatic install process.
Now you can execute cordova build android from the root, bob's your uncle.
As of 6/13/14 this is what works for me, so I laid out my steps on PasteBin.
http://pastebin.com/WvQvqx6U
Basically just reverted back to 0.4.0 of Facebook Connect.
It's working perfectly for me, and I didn't have any issues setting it up.

phonegap Hello World Example - Cannot call method 'getPicture' of undefined", source: file:///android_asset/www/index.html

I am trying to build the Hello world example which comes along with phonegap-2.9.1 (phonegap-2.9.1\lib\android\example) in Eclipse. I get the app launched but when I click on "Capture Photo" It gives me following error -
file:///android_asset/www/index.html: Line 67 : Uncaught TypeError: Cannot call method 'getPicture' of undefined", source: file:///android_asset/www/index.html (67)
I have HelloWorld-CordovaLib project as well which is included as Lib in "Hello World" example so I don't need to build the cordova.jar
Another request, I am feeling its difficult to get started easily with phonegap. If you can point me to some good sites (other than phonegap itself) where I can plugin myself with phonegap community that would be helpful.
Have you installed camera plugin, set all the permissions in AndroidManifest.xml & add the following code in config.xml?
<feature name="Camera">
<param name="android-package" value="org.apache.cordova.camera.CameraLauncher" />
</feature>

Phonegap 3.3.0 inappbrowser' s events are not firing

I use phonegap to develop an app. This app works with some apis so, i have to use inappbrowser plugin. But after phonegap 2.9.x versions, the plugin's events are not firing. You can look at this problem on this forum https://groups.google.com/forum/#!topic/phonegap/e5_5unC2fYs
. Apache has an announcement about it.announcement But it is not a solve. Because, when i try to use phonegap with dreamweaver, i can choose phonegap 2.9 version in Dreamweaver Build service and Inappbrowser events work on Android 4.x devices. So, the problem is not about Android version. The problem is about Phonegap version. For some sdks(admob,...) i have to use eclipse. And i cant create a Phonegap 2.9 version app with command line. Do you have any idea about to choose version when creating app. Or change downgrade phonegap version.
Thanks for you answers.
I haven't tested it myself, but if you're using phonegap build, you can try to include plugins in this format:
<gap:plugin name="org.apache.cordova.inappbrowser" />
, as well as the documented:
<feature name="InAppBrowser">
<param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser" />
</feature>
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
</feature>
see this page for plugin details
I had some trouble upgrading from 2.9.0 to 3.3.0, and it turns out I included my plugins in this format:
<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />
, which for some reason didn't work, when I used the format my plugins started working again.
Hope this helps.
It turns out that my issue was not that the events weren't firing, but that there was a bug in my callback code (a ReferenceError). Since this callback was the first callback to be run when the InAppBrowser received a "loadstart" event, all future callbacks did not run since the first callback raised an exception, making it seem like the InAppBrowser wasn't firing any callbacks at all.
The way I found this was actually by manually evaluating the callback in weinre.
cordova.require('cordova/exec').nativeCallback('InAppBrowser115751764',1,
{
"url" : "http:\/\/example.com\/path",
"type" : "loadstart"
}
,1)
I got the above snippet by reviewing the verbose PhoneGap exec logs. You should also be able to find the callback ID by inspecting the cordova.callbacks object.
Try install cordova:
sudo npm install -g cordova
install plugin inappbrowser:
cordova plugin add org.apache.cordova.inappbrowser
now run:
phonegap run android

Error initializing Cordova: Class not found

I followed the tutorial of Phonegap from the official Phonegap.com site (getting started with Android).
I have created project with following all the steps.
created activity and extended from "DroidGap" and added loadURL method from onCreate().
Added cordova-2.0.0.js and cordova-2.0.0.jar on the respective folder.
Added the jar file to the build path
Loaded the js file from the html tag
Added permissions from AndroidMainfeast.xml
copied the xml folder containing "configs.xml"
Now I don't understand where's the problem. It is showing the below error as shown in the screenshot
Here is my HTML file
<!DOCTYPE html>
<html>
<head>
<title>Notification Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
// Empty
}
// Show a custom alert
//
function showAlert() {
navigator.notification.alert(
'You are the winner!', // message
'Game Over', // title
'Done' // buttonName
);
}
// Beep three times
//
function playBeep() {
navigator.notification.beep(3);
}
// Vibrate for 2 seconds
//
function vibrate() {
navigator.notification.vibrate(2000);
}
</script>
</head>
<body>
<p>Show Alert</p>
<p>Play Beep</p>
<p>Vibrate</p>
</body>
</html>
Any advice? Thanks!
It is config.xml not configs.xml.
Based on the logs I'm seeing you are missing this file in your apps res/xml directory. It is included as part of the distribution at lib/android/res/xml/config.xml so copy that file into your res/xml directory and you should be all set.
Just as aharris88 in his answer to this question, I had the [CORDOVA] Error initilizing Cordova: Class not found error message when using Cordova 3.1.0 on my Android dev phone after migrating from Phonegap 3.0.
All fiddling with the config.xml file in the /platforms/android/res/xml directory did not help. Based on the Stackoverflow answer mentioned above, I tried to "start over" by reinstalling Android platform support:
cordova platform rm android
cordova platform add android
After this step it worked again, and I was able to cordova build android && cordova run android without any further problems.
I have had this error because of a plugin that I deleted. I Added
<plugin name="Device" value="org.apache.cordova.Device"/>
to the config.xml file again and it fixed it.
My you not have following plugin:
<plugin name="Device" value="org.apache.cordova.Device"/>
You have to put that in between <plugins></plugins>.
like
<plugins>
<plugin name="Device" value="org.apache.cordova.Device"/>
</plugins>
Well,the error I found is:
05-28 08:19:53.139: E/PluginManager(1478): =====================================================================================
05-28 08:19:53.139: E/PluginManager(1478): ERROR: config.xml is missing. Add res/xml/config.xml to your project.
05-28 08:19:53.139: E/PluginManager(1478): https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=blob;f=framework/res/xml/plugins.xml
but I found /res/xml/config.xml in my project
finally,I found error in org.apache.cordova.api.PluginManager:
public void loadPlugins() {
int id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getClass().getPackage().getName());
...
should change to:
public void loadPlugins() {
int id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getPackageName());
...
you could read more about the method "getIdentifier(String name, String defType, String defPackage)" in offical doc
I had this problem using phonegap 3.x and the problem turned out to be that phonegap hadn't properly installed the plugins, or they just messed up along the way. Basically when you install the plugins and build for a platform it takes the javascript files from plugins/org.apache.cordova.core.specific-plugin/www and puts them in platforms/android/assets/www/plugins/org.apache.cordova.core.specific-plugin/www and then it takes the Java files (or objective C for iOS) and puts them in platforms/android/src/org/apache/cordova/specificplugin
And all of this is specified by plugins/org.apache.cordova.core.specific-plugin/plugin.xml. If you look in a plugins.xml you should see something like:
<source-file src="src/android/NetworkManager.java" target-dir="src/org/apache/cordova/networkinformation" />
So this tells you that in platforms/android/src/org/apache/cordova/networkinformation, there should be NetworkManager.java. And that file can be copied from plugins/org.apache.cordova.core.network-information/src/android/NetworkManager.java
Now all of this is supposed to happen automatically without having to touch the platforms folder. But if it messes up you can fix it by manually copying the correct files into the correct folders.
You can resolve this when using phonegap command line by doing the following:
Delete merges/android, platforms/android, plugins/android.json
run phonegap local build android
Had same problem with Class not found. One problem to look at is to ensure that the android.json (or ios.json) file is being updated on a build. Mine was effectively empty.
Also, remove and add back the plugins as mentioned in some other posts.
Finally, the thing that worked for me was to ensure that the plugins were corrected referenced in the config.xml:
<feature name="Device">
<param name="android-package" value="org.apache.cordova.device.Device"/>
</feature>
<feature name="Camera">
<param name="android-package" value="org.apache.cordova.camera.CameraLauncher"/>
</feature>
<feature name="Notification">
<param name="android-package" value="org.apache.cordova.dialogs.Notification"/>
</feature>
Note the double naming of 'device.Device' and also the sub-classing of the 'camera' and 'dialogs' plugins. This just isn't properly referenced by the Phonegap documentation.
So After near to kill myself , i found that i was using cordova version 5.3.3 and cordova-android version 5.0.0, somehow i don't know may be there are not compatible or there can be a bug ,so i fall back to cordova android 4.1.1
cordova platform rm android
cordova platform add android#4.1.1
and this saved me up
I ran into the same error: "Error initializing Cordova: Class not found", using cordova with visual studio 2015. But this wasn't the only error, none of my plugins seem to get trough. I've tried about EVERYTHING. From cordova platform rm/add android x1000 times, to deleting and re-adding the plugins manually, nothing seem to do the trick.
Then i changed my cordova-cli in the taco.json file from 5.3.3 to 5.4.0 and ran it on my device. Finally this fixed the whole issue for me. I then downgraded the cordova version back to 5.3.3 ( the 5.4.0 version is not supported by the adb bridge as of yet ). Try it out!
I'm getting the same error, I checked my Cordova plugin list
by running the command "cordova plugin list" in my Android project directory and found "org.apache.cordova.device" plugin missing.
I updated it using "Cordova plugin add cordova-plugin-device" and Error was gone.
[Solved in my case]
First, step six is wrong: it is config.xml and not configs.xml
I have the same error despite I have my config.xml in res/xml folder.
It is because you have to install manually plugins for basic API functions.
Through console navigate to your project folder and type:
phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
You can read more here in phonegap Doc (last section called add features) : Phonegap Doc
I leave you also my config.xml file
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.helloCordova" version="2.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name short="Menu">Menu Digital</name>
<description>
Description
</description>
<author email="asd#gmail.com" href="www.facebook.com/usr"> Name </author>
<feature name="App">
<param name="android-package" value="org.apache.cordova.App" />
</feature>
<feature name="http://api.phonegap.com/1.0/device" />
<feature name="http://api.phonegap.com/1.0/media" />
<feature name="Device">
<param name="android-package" value="org.apache.cordova.device.Device" />
</feature>
<content src="index.html" />
<feature name="App">
<param name="android-package" value="org.apache.cordova.App" />
</feature>
<access origin="*" />
<preference name="useBrowserHistory" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
</widget>
This could happened 'cause your cordova plugin have a different path from what IONIC expect to found:
You should correct the file plugin.xml inside your plugin source folder:
<config-file target="app/src/main/res/xml/config.xml" parent="/*">
should be:
<config-file target="res/xml/config.xml" parent="/*">
If you try to searching that error inside the Android Studio Logcat usually you find something like:
io.ionic.starter E/chromium: [ERROR:service_manager.cc(156)] Connection InterfaceProviderSpec prevented service: content_renderer from binding interface: blink::mojom::BudgetService exposed by: content_browser
2019-02-22 13:40:06.144 30230-30258/com.android.webview:sandboxed_process0 E/chromium: [ERROR:BudgetService.cpp(167)] Unable to connect to the Mojo BudgetService.

Categories

Resources