Geolocation is not working on android


I test the code on web browser and iOS, it works perfectly. but on android i get error message :
console.log: Error: Only secure origins are allowed (see: Is there any solution to this problem?


This is something I believed was fixe in the cordova-plugin-geolocation a few release ago.
Chances are you have an older version that does not include the fixes.

ionic plugin rm cordova-plugin-geolocation

ionic plugin rm cordova-plugin-geolocation@latest --save


I did this:
ionic plugin rm cordova-plugin-geolocation

ionic plugin add cordova-plugin-geolocation@latest --save

but i get same error. here is my code:

  (position) => {
    const geofence = this.geofenceService.create({
      longitude: position.coords.longitude,
      latitude: position.coords.latitude,
           //{ lat: position.coords.latitude, lng: position.coords.longitude });

  (error) => {
    console.log('Error: ' + error.message);

  { timeout: 10000, enableHighAccuracy: true }

ionic info
system information:

Cordova CLI: 6.5.0
Ionic Framework Version: 2.0.1
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.0.0
ios-deploy version: 1.9.1
ios-sim version: 5.0.13
OS: OS X El Capitan
Node Version: v7.5.0
Xcode version: Xcode 8.2.1 Build version 8C1002


Just google your error and found that post, maybe it could help:


I read this, but what is a solution to this problem?


Somewhere http is use instead of https…but I personnaly don’t know the solution, just wanted to give a clue

here similar topics


Thanks reedrichards, a lot of people are facing same issue but still no solution, all are searching for the solution.


What worked for me was editing the Android Manifest as stated here:


Thanks all, issue is resolve by updating plugins and not using livereload in run command.


OMG thanks a lot for this comment!! NOT using --livereload in Android made it happen to work, finally!!


Thanks for the comment “not using --livereload”. Now working for Android.


Dear Hassan,
I am facing still this issue. please explain how did you fix it? Thanks…


would you like to change the second line from remove to add?


I succesfully solve this issue :slight_smile:


how please tell me ,attached some codes


Follow this link this might be work:


Hi all, we’ve put together this guide for testing Geolocation on Android in the emulator. I’ve run into the same issues others have here, and these tips resolve them:


I simple remove the security from Chrome with this command.

In MacOs:
open -a Google\ Chrome --args --disable-web-security --user-data-dir

In Linux:
google-chrome --disable-web-security --user-data-dir

This remove security and Cross-Origin too.




@hassanShahzad Still i am facing the same problem.I update the all plugin but still its not working in android device.can you please guid me step by step?