Phonegap 3 Custom plugin not working - android

I've build an application 6 month ago with phonegap 2.6.0. My application works great. I want to update my application with phonegap 3. I use the CLI to create the project, I copy and paste all the files in the new project. I had with the CLI the needed basic plugin (device information, camera...). this work.
But now, I've custom plugin that I've written that I need to put in my new project.
My question is: Do I need to rewrite all my custom plugin in order to get it working with phonegap3? Is there a way to use my "older" plugin in phonegap 3?
Thank you

Do I need to rewrite all my custom plugin in order to get it working
with phonegap3?
Yes, you will need to rewrite your plugin to use the new Cordova/phonegap. This is because a lot of things changed between how plugins interact with the main thread (on the native side) and how the JavaScript code is loaded into the page (now it uses require.js and AMD modules instead of just injecting the plugin code into window.plugins object.
Is there a way to use my "older" plugin in phonegap 3?
Unfortunately, no, there is no way that I know of to use old plugins.
Hopefully it won't take that much effort to rewrite your plugin. There isn't a plugin upgrade guide yet but it is something that is needed - as you do this upgrade, feel free to take notes about what you needed to do and donate those notes back to the community. This would be a tremendous help in starting the plugin upgrade guide.
I'd recommend going through these two docs:
Android Plugins
Plugin Development Guide
You could also probably look at the changelog for official Cordova plugins to see what they had to do between versions, but it might take some effort to determine the difference between bug fixes and updating the plugin code to work with new Cordova versions.

Related

Is there a way to use android application functionality on cordova?

I have two applications one is running on android java,the other one is a cordova application. I need to use the android functionality on the cordova app. is therere a workround to this? I have been scratching my head for a week.
I have looked into Android plugins but i don't really know how to glue them together. I know Cordova can communicate back and forth with native code. But since i am an android developer and i have little idea on how cordova works with plugins Am Stuck with just my plain Android App built on java.
If you have a custom requirement, then your best shot is creating a plugin for Cordova which is well documented in the cordova docs. It will guide you on how to build as well as publish a plugin for Cordova.
Once you publish a plugin, you can add it using
cordova plugin add <plugin_name>

Cordova Plugin - Is there a tool to generate JS interface automatically?

Just want to know if is there any tool to generate the Javascript interface for a Cordova Plugin automatically?
That would be very helpful.
For example, once you are done with the native part of a Cordova Plugin, for example on this tutorial:
https://taco.visualstudio.com/en-us/docs/createplugintutorial/
When you arrive to the Step 3 you need to create the Javascript plugin. How is that process?, is there any way to make it easy?
I haven't heard of one. There are probably a couple reasons for this:
IIRC, the whole idea of plugins as a separate thing from the core functionality of Cordova was not very well defined prior to the Cordova 3.x release. Even afterwards, it took a while for things to standardize on npm as a plugin repository. Someone with a better memory might be able to fill this in.
There's not much incentive for the Cordova guys to create a plugin interface tool. Most of their clients' (read: our) dev work is in the HTML5 layer -- plugins are mostly just a polyfill to the stuff that HTML5 can't get to on the device.

how to make a cordova android plugin using external non-builded lib (OpenCV)

I'm trying to create a cordova plugin to use OpenCV on android and iOS.
I am for the moment at the android part.
I downloaded the OpenCV android package, and create a test application with android. That work, so I just need to put that in the plugin.
But I have absolutly no idea about how to import the OpenCV library in the plugin.
Someone know how to do that ?
Thanks in advance
Have you written a cordova plugin in the past? If not, this is probably not the easiest place to start (if you haven't start with the plugin guide from the Cordova team.).
Including JNI (native code) in Android in Cordova plugins is a bit of black art, but you are lucky that someone has gone there before (and abandoned) a
Cordova OpenCV plugin for Android. Study that, and then for iOS it is a lot easier, since you can CocoaPods or just include the library and don't have to worry about C/Java bridge. If all of this is making your head hurt and you have no idea what JNI is then you might want to farm out the writing of this kind of plugin to someone else.
EDIT
I was going to add this in a comment but it was too long:
An apk is a complete App and not a Library.you need to include the various .so files (shared objects) for openCV. If you want to learn how to link a C++ file into an Android app (first step of creating a Cordova Plugin with JNI check out this tutorial. However, since half the work has already been done for you, what I would do is just download the OpenCV Plugin into a directory and then
cordova plugin install
and fix what you need (if you get everything working, think about forking the original project and contribute back to the community :) ).
As stated the plugin for iOS will be similar to other IOS plugins, maybe look at the cordova-cocoapods project, the other cordova-cocoapods project and the OpenCV CocoaPod.

Implementing plugin in phonegap

I am developing android mobile application using phonegap.I want to implement “ContactPicker plugin“ from github webstie.For implement plugin I refered below article
"https://github.com/sconover/phonegap-android-plugin-examples"
In above article they explained the path of plugin, But on my machine I did not find the path
"src/com/phonegap/HelloWorldPlugin/HelloWorldPlugin.java” In my plugin. Also I was unable to get the file HelloWorldPlugin.java
I tried to install plugin using command line tool but not sure its installed or not.
I am unable to use this plugin in my phonegap application. I am stuckup with very basic step of copying files and using the same in phonegap.
Don't use old plugins, this one is about four years old. A lot of things changes since 2010.
Use the original cordova plugin: org.apache.cordova.contacts

How to combine Cordova, Crosswalk and Ionic framework

I'm trying to create a mobile application which combine the above projects and I'm not sure how should I do it.
Here are 2 options which I found:
Use https://github.com/MobileChromeApps/mobile-chrome-apps - My problem with it is that it seems that it's not production ready. (I was told that it is but I can't find any support for that).
Create a new ionic project, then add Cordova to it followed by empting the platforms/android/CordovaLib/ folder and moving into it files from Crosswalk (as explained at https://www.thepolyglotdeveloper.com/2014/10/use-crosswalk-ionic-framework-android-apps/) - This solution is quite simple but seems a little hackish for me...
Which option should I use? are there any other options?
Cheers,
---- Update ----
Ionic have incorporated the ability to combine Crosswalk in their own CLI, check it out at http://ionicframework.com/blog/crosswalk-comes-to-ionic/
Regarding Crosswalk
Crosswalk support is something that we hope will be available to vanilla cordova by default before the end of the year. You can start experimenting with this today by following the work on the cordova-android 4.0 development branch. It should be possible to add this platform (and the required plugins) directly to a new ionic project.
Chrome Apps for Mobile are cordova-cli compatible and do indeed already bundle Crosswalk by default. The primary difference with vanilla cordova is that applications must follow the Chrome Packaged App structure (have a manifest and background script), but gain the benefit of running on Desktop Chrome. See longer answer here. (I wouldn't read too much into the developer preview label.. we just like calling everything beta ;)
The current crosswalk-project.org provided cordova workflow does not use a cordova multi-platform application structure. It uses the cordova-android native app template directly. This means you will not be able to use the cordova cli, nor downstreams like cca or ionic. You will also obviously not be able to add other platforms, will have a tougher time upgrading, and managing plugins is a bit more complicated (you have to use the plugman tool directly).
There is currently no option for developing using cordova+crosswalk that is not without some tradeoff.
Regarding compatibility between Cordova, Ionic, Chrome Apps for Mobile (etc) projects
Most cordova downstream projects are "mostly" cli compatible. E.g. The cca cli (used by Chrome Apps for Mobile) supports commands like create, plugin add and platform add -- so it will work to install ionic plugins. Vice versa is also true, Chrome Api's for Mobile are developed as cordova plugins which can be added to an Ionic or cordova project using their respective cli's.
Most downstreams also use the same project directory structure (plugins/, platforms/, www/, hooks/, etc), so you can usually mix usage of the various cli's within one project to some degree.
That said, the reason cca needed a custom cli is because we do a few non standard modifications to your cordova project that aren't directly supported by vanilla cordova (yet). Ionic does the same.
I've suggested at various cordova meetups that downstream projects like Ionic, PhoneGap, and CCA, should play better together -- so your question is right on the money. We are mostly-compatible but finding out the differences is currently left as an exercise to the developer.
Using XDK HTML5 Cross platform Development IDE is probably the best way of integrating Crosswalk, Cordova and Ionic. It has built in support for Crosswalk. I have recently used it and its totally awesome. It will make our work a lot easier.
From Crosswalk site:
If you prefer to use a graphical integrated development environment (IDE), the free Intel XDK provides an alternative way to package applications for Crosswalk Android. See the Intel XDK website for more details.
This guy on youtube produced a nice, straight-forward tutorial that worked for me: https://www.youtube.com/watch?v=0I1OjJLVLMo
The results are fantastic, worth the struggle to get it working.
The guy says CrossWalk makes a big difference on anything running less than Android 4.4 (when Chromium was added).
Good luck.

Categories

Resources