Phonegap geolocation plugin is not adding for android - android

Geolocation
I am trying to get geolocation details , i have added geolocation plugin using cordova command line
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git
$ cordova plugin rm org.apache.cordova.core.geolocation
Application created using cordova commandline
The Command-Line Interface
After adding plugin through command line android plugin is missing
in the following screenshot android is missing
Can anybody please help me ?

The native code for Android Geolocation was removed, see the deprecation bug. This was because the native implementation was buggy and the native browser geolocation works fine. Since Cordova (Phonegap)'s goal is to not exist, it was only a matter of time until this was removed. You can use Geolocation just like you normally would, it just won't use the native code and instead rely on the browser version.
If you look in the plugin xml file, you will see that there is still some lines in there about Android. This is so that cordova plugin add org.apache.cordova.geolocation will correctly copy in the needed permissions to run on Android.

Check this link : Go to Add Plugin Features
Add Plugin Features
You can use the CLI to search for plugins from this registry.
For example, searching for geolocation produces a single result that matches terms as case-insensitive :
Just search for plugin in command prompt.
cordova plugin search geolocation
By firing above command you will get search result as :
org.apache.cordova.geolocation - Cordova Geolocation Plugin
Now to install this plugin you need to fire :
cordova plugin add org.apache.cordova.geolocation
You will get result as :
Fetching plugin "org.apache.cordova.geolocation" via plugin registry
Installing "org.apache.cordova.geolocation" for android
Finally, the geolocation plugin will be installed in your application_name/plugins directory.
Path will look as : D:\PhoneGap\hello\plugins\org.apache.cordova.geolocation

Here are the steps to make you happy.It took a whole day for me to sort out this.
Better you downgrade the version of geolocation plugin. Go through below steps:
a)Remove the already downloaded geolocation plugin:
phonegap plugin rm org.apache.cordova.geolocation
b)Add the downgraded geolocation plugin:
phonegap plugin add org.apache.cordova.geolocation#0.3.2
Now you will see the android folder under the plugins folder.
Cheer up!!

Related

How to test cordova plugin while developing?

Can someone suggest a better way to test cordova plugin while developing it.
Right now the plugin is not pushed to github nor npm.
I am adding the plugin to my cordova android project using this command.
cordova plugin add cordova-test-plugin
But if I make any modifications to the plugin in the plugins/ folder, those changes are not reflecting.
How can I test the plugin while making changes.

Local notifications with "cordova-plugin-local-notifications" plugin

I am trying to add the cordova-plugin-local-notifications plugin to my android project.
I am adding implementation 'com.github.katzer:cordova-plugin-local-notification'under dependencies, into my app gradle file. But Gradle can't find the plugin.
Error: Supplied String module notation 'Failed to resolve: com.github.katzer:cordova-plugin-local-notification:
Plugin link: https://github.com/katzer/cordova-plugin-local-notifications/
Thank you for your help.
You need to follow steps from tutorial:
https://cordova.apache.org/docs/en/latest/guide/cli/
Here you may find how to install Android if not yet:
https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#requirements-and-support
and how to install plugins.
You haven't installed the plugin properly. You have not even installed the Cordova CLI properly, according to your comments.
If you are new to Cordova, I strongly recommend you to try an IDE like Visual Studio with the tools for Apache Cordova and set it up following this guide. Plugins must be properly installed before they can be used in your apps, and of course Cordova needs to be installed first.

Can't add downloaded plugin to Cordova/Phonegap project

How can I get a plugin to work by installing it NOT from the repository.
Each plugin I try to install using phonegap plugin add <<git repository>> always results in different errors, because windows + npm just doesn't want to work for me...
This is the plugin I need: https://github.com/VersoSolutions/CordovaClipboard
My steps:
Download Git repository
Run phonegap plugin add <<downloaded and extracted directory>>
Remove and add android platform (yes it says that it installed the plugin)
Start Phonegap Developer app
But cordova.plugins.clipboard is still undefined. Do I have to put the clipboard.js file somewhere or reference it? If so, which version?
The one in the clipboard project or the one phonegap automatically creates within the platform/android directory (it puts a "define" around it). I actually tried both, but the object was still undefined.
The clipboard plugin does not have a package.json present which is why you are getting the error. You can either add a package.json file to the plugin or you can install it with the --nofetch flag:
cordova/phonegap plugin add https://github.com/VersoSolutions/CordovaClipboard.git --nofetch
Since cordova 7.0.0 npm install is run by default when adding a new plugin which causes an error if no package.json is present. You can find the release notes for cordova 7.0.0 here.

How to update the already added Cordova plugin

I'm the development of cordova plugin in android.
Updating the javascript of Cordova plugin are not updated.
change:"./test/plugins/cordova-plugin-whitelist/whitelist.js"
cordova build android
Expect the update:/test/platforms/android/assets/www/plugins/cordova-plugin-whitelist/whitelist.js
In the version up of cordova it seems behavior has changed.
5.3.3-: OK
5.4.1+: NG
Thank you,
Instead of updating the plugin, I've found that I can remove it and re-add it. In my case, I'm referencing the plugin source code locally, via the --link option:
cordova plugin rm plugin-name
cordova plugin add custom-plugins/plugin-name --link
To make sure the correct version number is reflected in the newly added plugin, you can use:
cordova plugin ls
Run The below command
cordova plugin update plugin-name

Cordova Android platform upgrade from CLI 3 to 4 breaks build

I'm running cordova 5. I used to have the android platform 3.7.1 and everything was fine.
Today I upgraded the android platform to 4.0.2 (cordova platform android update#4.0.2). Since then, my compiled projects get a 404 error when trying to load remote .js scripts. Went back to 3.7.1 and it works.
What's the proper way to upgrade a Cordova Android project? Is there a new setting for network access?? Something I missed in the upgrade?
Posting the answer..
So far, the only way for me to make my project work again was to create a new cordova project and re-import plugins and edit config.xml. I tried upgrading the current project in its current folder but it would never work even if the upgrading was a success (according to cordova). Bottom line: upgrading does not work.
If you're running cordova 5.0 the chances are you haven't installed the white-list plugin.
cordova plugin add cordova-plugin-whitelist
or if you want to save the reference to your config.xml file:
cordova plugin add cordova-plugin-whitelist --save
You can find more info here.
This is because cordova uses cordova-android#4.0.0 as the default version now.
http://cordova.apache.org/announcements/2015/04/15/cordova-android-4.0.0.html
You need to add the whitelist plugin as described by #LeftyX earlier.
cordova plugin add https://github.com/apache/cordova-plugin-whitelist.git
But then you also need to edit the config.xml to allow access to your sites - the whitelist plugin only allows access to file URLs by default.
The easiest way to restore functionality is to add:
<!-- A wildcard can be used to whitelist the entire network,
over HTTP and HTTPS.
*NOT RECOMMENDED* -->
<allow-navigation href="*" />
But as you can see, that is not recommended.
You should really lock it down to make it more secure.
Other options are documented in the README for the whitelist plugin.
https://github.com/apache/cordova-plugin-whitelist
Source: After I performed both the steps mentioned above, my 404s disappeared.

Categories

Resources