Tuesday, July 24, 2012

Updates to Plugins for PhoneGap 2.0.0

I've spent a bit of time this morning updating the plugins that I'm nominally responsible for on Android so that they conform and work with the PhoneGap 2.0.0 API. You should be able to get the following plugins from the github plugins repo and just drop them into your project using the latest version of PhoneGap. I've also kept around the code from the previous versions of the plugin for folks using older PhoneGap versions.


  • Application Preferences
  • Barcode Scanner
  • Child Browser
  • IMEI
  • Video Player
The next step in the plugin migration to the new API will be to conform with Andrew Lunny's proposal for a Cordova Plugin Spec. Moving to this spec will make it much easier for PhoneGap dev's to discover and install plugins. Yup, exciting things are coming down the pipe. I'm going to work on that as soon as I can but I wanted to make sure I got these updates out before my vacation.

Enjoy!

Update (2012/08/09): As of PhoneGap 2.0 the plugins.xml file has been deprecated. It has been replaced with config.xml. So if you are starting a brand new project that has config.xml in the res/xml directory you will need to add your plugin declarations to this file. If you are using an older version of PhoneGap or upgrading an older project to PhoneGap 2.0 you can still use the plugins.xml file as we've got backwards compatibility (sort of). Please note though config.xml will take precedence over plugins.xml so you should not have both files in one of your projects as you'll end up tearing your hair out.

32 comments:

Libby Baldwin said...

You're changes are so great: clearly distinguishing plugin versions for cordova <1.8.1 versus 2.0.0. Thanks!

I may not have been paying attention lately.. is it accurate to say that res/xml/config.xml === plugins.xml + cordova.xml? Either way is supported in 2.0.0, but may change in the future?

Simon MacDonald said...

@Libby

Well the current thinking is all platforms will be moving to config.xml so expect plugins/cordova.xml to go away in the future. I would have preferred that we would have decided on what is in config.xml before introducing it in Android but Joe rushed it into 2.0.0. Expect some tag name changes going forward.

Belcho said...

Thank you very much for this update, I have been waiting for a long time. I'll test later how it's workign.

Libby Baldwin said...

I just realized you must be saying that 1.9.0 is to be chucked over the fence, so to speak.

Collective groan still audible..

niva said...

hai simon i used ur link for keyboard but i have a problem how to solve this?kindly solve this issuehttps://groups.google.com/forum/?fromgroups#!topic/phonegap/MB4xrmCYmvc,http://stackoverflow.com/questions/11686368/show-hide-keyboard-is-not-working-propery-in-android-phonegap#

Olivier said...

What about 1.9.0? Does the plugin spec has been frozen yet? Should I update my plugins accordingly? Will they work correctly with the current 2.0 release?

Thanks!

Ashwini said...

Hi all,

I have tried to integrate twitter in Android using phonegap 2.0 version.But what happens is when I tap on Start Twitter oAuth button I am getting the message Getting authorization, but it is not redirecting to the next process. I have done using phonegap1.9.0 successfully. But could not do using 2.0ver. What may be the problem and what's the solution?

Regards
Ashwini

nicoprofe said...

Simon, I 'm new to Phonegap but I can see the amazing work thath you are doing for the phonegap comunity. Could you please make an update for the Low Latency plugin for Cordova 2.0.0? I am looking for help a long time ago...
Thanks!

imin said...

Thanks for this plugin Simon, but I think you should update the documentation on inserting the line into config.xml and not plugins.xml. Newbie like me stucked hours figuring out why your plugin didn't work, and a good soul at stack-overflow pointed out I should write the plugin line into config.xml instead. Anyway, thanks again for this awesome plugin!

Simon MacDonald said...

@imin

Yeah, I will update the post to mention that. If you are using the old plugins.xml file it will work but if PhoneGap detects a config.xml it will use that first.

Simon MacDonald said...

@nicoprofe

That actually isn't one of my plugins. You can tweet at Andrew Trice and as him to update it. Alternatively, you could follow my instructions from this post to update the plugin to 2.0.0 yourself. Then send a pull request to the repo to have your name immortalized in open source software development history.

Simon MacDonald said...

@Ashwini

Come on over to my Formspring account as this sounds like it would be a bigger discussion.

Olivier said...

@Ashwini I had a similar issue with the 2.0 release with a Facebook SSO not returning correctly anymore. I did post an issue on the JIRA tracker, but unfortunately the team dismissed it (https://issues.apache.org/jira/browse/CB-1161).

I would not recommend using 2.0 in production as it has some strange bugs for android.

Simon MacDonald said...

@Olivier

Hmmm...that is odd. I can't get into JIRA right now as it is down. I've been away for a bit and I'd like to look into this some more. Are all the details in the JIRA ticket?

Simon MacDonald said...

@Olivier

Undoubtably you've seen my posts on how to upgrade your plugins. I've gotta set up a meeting with other core PG Plugin developers to put together the plugin roadmap.

Simon MacDonald said...

@Libby Baldwin

Yeah, I wasn't exactly happy with how 1.9.0 went down.

Domnic said...

Hi Simon,
I am using Cordova 2.0 and I am tryin to use the same version of the barcode scanner plugin. I am having an error..

TypeError: cordova.exec is not a function
[Break On This Error]

cordova.exec(successCallback, errorCallback, 'BarcodeScanner', 'scan', []);

is there something specifc I need to consider for the plugins tag in config.xml..?

my config.xml has an entry .. like





is this correct..?
thank you
Domnic

Simon MacDonald said...

@Domnic

I believe if you are the same person from the PG mailing list you were trying to load the barcode scanner before the cordova.js file.

Domnic said...

Hi Simon,
Thats true. I am still stuck up in running a code that can scan a bar code and get the results on an alert. I tried all possiblities.. I am sort of at the edge now.

I am getting this error:- Phonegap class not found exception when I am starting an app that uses the barcode scanner.

wish I had someone who can help me.
thanks
Domnic

Simon MacDonald said...

@Domnic

Zip up your project and post it somewhere and I will take a look at it.

Domnic said...

Hi Simon,
That is very kind of you.
https://docs.google.com/open?id=0B49NPqa2UD4GSVZsOUo1SEtRQUU

The error I am getting is..something related to the flashlight..and I tried to comment out the code that enables flashlight.. but still no improvements.

Hope you could give me a better insight.
thanks
Domnic


thank you
Domnic

Simon MacDonald said...

@Domnic

You are missing one of the key steps in your setup of a PhoneGap Android project. The main activity does not have the following attribute:

android:configChanges="orientation|keyboardHidden"

Without it the app will be restarted on orientation changes which is why this isn't working for you. See the getting started guide:

http://docs.phonegap.com/en/2.0.0/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android

as it is documented near the end of step 3.

HighTechMan said...

Hi Simon I got an issue on blackberry simulator using phonegap 2.0 any help please
gap:["NetworkStatus","getConnectionInfo","NetworkStatus(),true]
gap:["Device"."getDeviceInfo","Device1",true]
gap:["App","show","App2",true]
usePolling gap_callbackServer:
getPort gap_callbackServer:
gap_poll:

Simon MacDonald said...

@HighTechMan

I don't do the BB side very often. It looks like you are using the wrong cordova.js. Each platform has their own version of cordova.js.

Unknown said...

How do you add the following into config.xml for phonegap build?

android:configChanges="orientation|keyboardHidden"

Simon MacDonald said...

@Robert Frew

At the end of step 3 on this page shows how to add it to your manifest.xml.

Unknown said...

This looks like an active PhoneGap community so hopefully this is a good place to pose this question...As a veteran programmer but relative PhoneGap & Android newbie, does anyone know where I might find a PhoneGap plugin for the new Android ioio ("yo-yo")interface for hardware peripherals?

Simon MacDonald said...

@John Goluch

Sorry, I do not know of such a plugin.

Unknown said...

Hi Simon!

After I was trying to run my app with your plugin I got that logcat error when I'm tapping on the video to play:

Uncaught ReferenceError: cordova is not defined at file:///android_asset/www/scripts/video.js:10

I'm using the latest ver of phonegap, the 2.1.0. Have you got an idea, what could be the matter?

Simon MacDonald said...

@Ádám Metz

Did you make sure you loaded the cordova.js script file before the video.js script?

Unknown said...

Thanks for your reply Simon!

Meanwhile this annoying issue is solved, but I got another one, and I don't know how to fix it.

I have to tap twice on the link, that points to the required video to start playing immediately, just after the second tap.

here is my link
a href="#" onclick="playVideo('file:///android_asset/www/video/120508_Fragmin_Norge.3gp')

My question is: Is it possible to play the video after the first tap?

Thanks for your answer in advance!

Adam

Simon MacDonald said...

@Ádám Metz

There should be no reason why it doesn't play after the first click/tap.