Geolocation plugin gives errors when building an apk with gradle, using capacitor 3 beta 3

Upgraded to capacitor core@3.0.0-beta.3, cli@3.0.0-beta.3. Installed geolocation plugin separately (geolocation@0.4.0).
Imported geolocation in a pages ts file like that:

import { Geolocation } from ‘@capacitor/geolocation’;
Ran ionic capacitor build android and then tried to build an apk in android studio but it gives errors (removed the complete paths to the .java files):

error: cannot find symbol
import com.getcapacitor.PermissionState;
^
symbol: class PermissionState
location: package com.getcapacitor

GeolocationPlugin.java:11: error: package com.getcapacitor.annotation does not exist
import com.getcapacitor.annotation.CapacitorPlugin;
^
GeolocationPlugin.java:12: error: package com.getcapacitor.annotation does not exist
import com.getcapacitor.annotation.Permission;
^

GeolocationPlugin.java:13: error: package com.getcapacitor.annotation does not exist
import com.getcapacitor.annotation.PermissionCallback;
^
GeolocationPlugin.java:17: error: cannot find symbol
@CapacitorPlugin(
^
symbol: class CapacitorPlugin

GeolocationPlugin.java:53: error: cannot find symbol
@PermissionCallback
^
symbol: class PermissionCallback
location: class GeolocationPlugin

GeolocationPlugin.java:101: error: cannot find symbol
@PermissionCallback
^
symbol: class PermissionCallback
location: class GeolocationPlugin

GeolocationPlugin.java:20: error: duplicate element ‘<any?>’ in annotation @<any?>.
@Permission(strings = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION }, alias = “location”)
^
GeolocationPlugin.java:20: error: duplicate element ‘<any?>’ in annotation @<any?>.
@Permission(strings = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION }, alias = “location”)
^
GeolocationPlugin.java:42: error: cannot find symbol
requestAllPermissions(call, “completeCurrentPosition”);
^
symbol: method requestAllPermissions(PluginCall,String)
location: class GeolocationPlugin

GeolocationPlugin.java:55: error: cannot find symbol
if (getPermissionState(“location”) == PermissionState.GRANTED) {
^
symbol: method getPermissionState(String)
location: class GeolocationPlugin

GeolocationPlugin.java:55: error: cannot find symbol
if (getPermissionState(“location”) == PermissionState.GRANTED) {
^
symbol: variable PermissionState
location: class GeolocationPlugin
GeolocationPlugin.java:90: error: cannot find symbol
requestAllPermissions(call, “completeWatchPosition”);
^
symbol: method requestAllPermissions(PluginCall,String)
location: class GeolocationPlugin

GeolocationPlugin.java:103: error: cannot find symbol
if (getPermissionState(“location”) == PermissionState.GRANTED) {
^
symbol: method getPermissionState(String)
location: class GeolocationPlugin

GeolocationPlugin.java:103: error: cannot find symbol
if (getPermissionState(“location”) == PermissionState.GRANTED) {
^
symbol: variable PermissionState
location: class GeolocationPlugin
15 errors

did you also update @capacitor/android@3.0.0-beta.3?

1 Like

I got the same problem . You saved my life. Thank you so much for your solution >Fixed after running
npm install @capacitor/android@3.0.0-beta.3

better install like this npm install @capacitor/android@next
It will install latest v3, which it’s RC.0 at the moment, so beta 3 is very old
(and do it for all the other packages, cli, core and ios)

1 Like