user623396
user623396

Reputation: 1547

"Illegal Access" on $cordovaGeolocation.getCurrentPosition

Using the cordova-plugin-geolocation I'm getting this error on Android:

PositionError {code: 1, message: "Illegal Access"}

I checked the plugins/android.json file and the permissions are present

{
  "xml": "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\" />",
  "count": 1
},
{
  "xml": "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" />",
  "count": 1
 }

Upvotes: 4

Views: 2851

Answers (3)

Ahmed Elashker
Ahmed Elashker

Reputation: 1000

Removing and reinstalling the geolocation plugin didn't solve the problem in my case. I had to remove and reinstall the entire android platform from cordova.

cordova platform rm android
cordova platform add android

Upvotes: 1

smukov
smukov

Reputation: 625

I was working with an Ionic 2 project and I got the same error.

I fixed it by manually adding the code below to plugins/android.json file:

{
    "xml": "<feature name=\"Geolocation\"><param name=\"android-package\" value=\"org.apache.cordova.geolocation.Geolocation\" /></feature>",
    "count": 1
}

Maybe this will help someone.

Upvotes: 0

user623396
user623396

Reputation: 1547

Somehow it got fixed just by doing

cordova plugin rm cordova-plugin-geolocation

and

cordova plugin add cordova-plugin-geolocation

Upvotes: 3

Related Questions