I have been trying to use this sample plugin for geofencing: FlutterGeofencing
When I call the method registerGeofence
I get the following error:
java.lang.IncompatibleClassChangeError: Found interface com.google.android.gms.location.GeofencingClient, but class was expected.
My Code is as follows:
void registerGeofence() async {
final firstPermission = await Permission.locationWhenInUse.request();
final secondPermission = await Permission.locationAlways.request();
if (firstPermission.isGranted && secondPermission.isGranted) {
await GeofencingManager.registerGeofence(
GeofenceRegion(
'mtv',
latitude,
longitude,
1000,
_triggers,
androidSettings: _androidSettings,
),
callback,
);
final registeredIds = await GeofencingManager.getRegisteredGeofenceIds();
debugPrint("registerGeofence -> registeredIds: $registeredIds");
} else {
debugPrint(
"right permissions not set: whenInUser:
${Permission.locationWhenInUse.isGranted}, always:
${Permission.locationAlways.isGranted}");
}
}
I have clone the github code and aa it to my project as follows:
dev_dependencies:
geofencing:
path: /local_path/FlutterGeofencing
Thanks