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
Related
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.
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>
I am trying to create a Cordova Plugin using IBM Worklight. I followed the instructions mentioned in the IBM Worklight Getting Started page, but while checking trying it on a device I get the following:
02-13 17:58:15.182: D/PluginManager(21057): exec() call to unknown
plugin: SamPlugin
I added the plugin in Config.xml as follows:
<plugin name="SamPlugin" value="com.samapp.plugins.samplugin.SamPlugin"/>
and then, i called the plugin from my JavaScript file as follows:
cordova.exec(success,failure,"SamPlugin","printMsg",[name]);
There are no errors while building the application.
Do I need to mention the plugin anywhere else?
Looks to me like the way you have declared the plug-in in config.xml is incorrect...
This:
<plugin name="SamPlugin" value="com.samapp.plugins.samplugin.SamPlugin"/>
Should be:
<feature name="SamPlugin">
<param name="android-package" value="com.testapp.SamPlugin" />
</feature>
The above is the way Cordova plug-ins are declared in Cordova 3.x; Worklight 6.1 uses Cordova 3.1.
The above assumes you are using Worklight 6.1, because you mentioned that you've followed a Getting Started training module, which is now based on Worklight 6.1... If you are using a different Worklight version, you must mention the version number.
For example - an application that implements a Cordova plug-in that shares a link to a question via the native email app installed on the device (this doesn't really matter, it's just a "scenario"):
HTML:
<button onclick="openExternalApp()">Share Question</button>
JavaScript:
function openExternalApp() {
var QUESTION_LINK = $(".question_link").attr("href");
cordova.exec(onSuccess, onFailure, "OpenExternalAppPlugin", "openApp", [QUESTION_LINK]);
}
function onSuccess() {
WL.Logger.debug("*** Plug-in executed successfully.");
}
function onFailure() {
WL.Logger.debug("*** Plug-in failed to execute.");
}
android\native\res\xml\config.xml:
<feature name="OpenExternalAppPlugin">
<param name="android-package" value="com.testapp.OpenExternalAppPlugin" />
</feature>
android\native\src\com\YOUR_APP\OpenExternalAppPlugin.java:
The Java file containing the Java code of the Cordova plug-in...
Using phonegap 3.1 I'm trying to hide the splash screen when device is ready:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
navigator.splashscreen.hide();
}
But it returns:
Cannot call method 'hide' of undefined
The navigator object doesn't including the splashscreen attribute.
I've tried it on phonegap 2.9 and it works fine.
After research and experiments this is what we had to do in order to get it work:
cordova plugin add org.apache.cordova.splashscreen
cordova build
Then, cordova build was adding the wrong lines to the config.xml - So we had to change it to the following:
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
</feature>
And in your main activity
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.setIntegerProperty("splashScreenDelay", 10000); //time to display the splash
Finally we have been able to use hide method from javascript.
Are you using the CLI to add the SplashScreen plugin? You have to add the plugin with $ cordova plugin add org.apache.cordova.splashscreen (copy the plugin code from plugins.cordova.io into /yourApp/plugins/org.apache.cordova.splashscreen/ and then later cordova build to copy the plugin code into the appropriate platform location.
If you're using phonegap build, rather than doing
cordova plugin add ...
from the command line, you'll need to add the plugin and feature to the config.xml:
<gap:plugin name="org.apache.cordova.splashscreen" />
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
<param name="ios-package" value="CDVSplashScreen" />
</feature>
Only thing I can guess is to double check that you have <script type="text/javascript" charset="utf-8" src="cordova.js"></script> in the head of your HTML that is calling that JS. Sorry, haven't messed with 3.1 yet.
Add this:
<preference name="SplashScreen" value="splash.png" />
<preference name="SplashScreenDelay" value="3000" />
The navigator.splashscreen.hide() doesn't work for me either.
UPDATE: navigator.splashscreen.hide() only works when building online (phonegap build).
After upgrading to Phonegap Desktop 0.3.6, I had a similar issue and one of my older apps was stuck on the splash screen. In the configuration window, it was showing the correct app name and version and it was updating as soon as I was modifying the config.xml. In the console I had only one error: 500 for http://localhost:3000/cordova_plugins.js
A new app was working fine.
I tried all the above:
splash screen plugin and configuration
adding the cordova.js and cordova_plugins.js to index.html. This is not necessary anymore since many versions ago - the build does it for you.
in the platforms/android/assets/www folder there were cordova.js and cordova_plugins.jsfiles present
in the config.xml there was specified <content src="index.html" />
In the end what solved my problem was to completely delete the platforms folder and run cordova platform add android again. I guess it's safe to do this after each Phonegap upgrade.
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.