bkonyi / FlutterGeofencing

Rough work for Flutter geofencing plugin
BSD 3-Clause "New" or "Revised" License
338 stars 220 forks source link

Example app: Failed to add geofence error #8

Closed angel1st closed 3 years ago

angel1st commented 5 years ago

I have simply cloned the repo, built and started the example app. I have got the following error, once I tapped on Register button:

E/GeofencingPlugin(17185): Failed to add geofence: com.google.android.gms.common.api.ApiException: 1000: E/flutter (17185): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception: E/flutter (17185): PlatformException(com.google.android.gms.common.api.ApiException: 1000: , null, null) E/flutter (17185): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551:7) E/flutter (17185): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:292:18) E/flutter (17185): E/flutter (17185): #2 GeofencingManager.registerGeofence (package:geofencing/src/geofencing.dart:149:20) E/flutter (17185): E/flutter (17185): #3 _MyAppState.build. (package:geofencing_example/main.dart:103:45) E/flutter (17185): #4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14) E/flutter (17185): #5 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:562:30) E/flutter (17185): #6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24) E/flutter (17185): #7 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9) E/flutter (17185): #8 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7) E/flutter (17185): #9 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9) E/flutter (17185): #10 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12) E/flutter (17185): #11 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11) E/flutter (17185): #12 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:180:19) E/flutter (17185): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22) E/flutter (17185): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7) E/flutter (17185): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7) E/flutter (17185): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7) E/flutter (17185): #17 _invoke1 (dart:ui/hooks.dart:168:13) E/flutter (17185): #18 _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5)

flutter --version
Flutter 1.0.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5391447fae (9 weeks ago) • 2018-11-29 19:41:26 -0800
Engine • revision 7375a0f414
Tools • Dart 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
frextrite commented 5 years ago

The call to start the geofence service goes even before the Location permission is asked by the app. You could manually give permission and then restart the app to solve the above issue.

OlivierMoitroux commented 5 years ago

I have exactly the same issue and used the package simple_permissions to be sure that all permissions were set to authorized before clicking on register. Indeed, they are all correct so it does not seem to be the real problem ... Anyone succeeded to make FlutterGeofencing works ?

I hope s.o. can help because this is a very promising work ! Good blog post too :)

frextrite commented 5 years ago

Also, make sure the location accuracy is set to high. Enable GPS+mobile data+WiFi accuracy(highest possible) in location settings.

magnus-lpa commented 5 years ago

I have the exact same problem on an Android 9 emulator. The problem persists even though the app has Location permission, Google Location Accuracy is activated and WiFi + Location + Mobile Data is turned on.

SDRuiz commented 5 years ago

did anyone resolve this issue? I can´t continue with my project, I tested almost all the Geofences APIs, but Android throw this PlatformException all the time.

E/GeofencingPlugin: Failed to add geofence: com.google.android.gms.common.api.ApiException: 1000: 
E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(com.google.android.gms.common.api.ApiException: 1000: , null, null)
    #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
    #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
timeuser commented 5 years ago

That error 1000 is a geofencing error from Android. I was able to fix it. I had to allow "Improve Location Accuracy" in Android settings so it could use WiFi, mobile networks etc. to improve location accuracy. It appearsr geofencing doesn't work without that enabled. Here are some related links:

https://developers.google.com/android/reference/com/google/android/gms/location/GeofenceStatusCodes.html#GEOFENCE_NOT_AVAILABLE

https://androidforums.com/threads/error-adding-geofence-on-android-8.1289302/

https://stackoverflow.com/questions/53996168/geofence-not-avaible-code-1000-while-trying-to-set-up-geofence

GadepalliAditya1998 commented 5 years ago

did anyone resolve this issue? I can´t continue with my project, I tested almost all the Geofences APIs, but Android throw this PlatformException all the time.

E/GeofencingPlugin: Failed to add geofence: com.google.android.gms.common.api.ApiException: 1000: 
E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(com.google.android.gms.common.api.ApiException: 1000: , null, null)
    #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
    #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)

This happens when you don't turn on the GPS

bkonyi commented 4 years ago

Yeah, this sounds like a permissions issue. Are you sure your permissions are all set correctly and that the GPS is enabled?