bkonyi / FlutterGeofencing

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

Neither user 10470 nor current process has android.permission.WAKE_LOCK #13

Closed magnus-lpa closed 5 years ago

magnus-lpa commented 5 years ago

Cloned the repo and trying to run the example app.

Location permission and high accuracy is granted.

This is what happens when I try to run it on a physical device (Huawei Honor 6X with Android 7):

I/GeofencingPlugin( 5453): Successfully added geofence
E/AndroidRuntime( 5453): FATAL EXCEPTION: main
E/AndroidRuntime( 5453): Process: io.flutter.plugins.geofencingexample, PID: 5453
E/AndroidRuntime( 5453): java.lang.RuntimeException: Unable to start receiver io.flutter.plugins.geofencing.GeofencingBroadcastReceiver: java.lang.SecurityException: Neither user 10470 nor current process has android.permission.WAKE_LOCK.
E/AndroidRuntime( 5453):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:3184)
E/AndroidRuntime( 5453):    at android.app.ActivityThread.-wrap18(ActivityThread.java)
E/AndroidRuntime( 5453):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1653)
E/AndroidRuntime( 5453):    at android.os.Handler.dispatchMessage(Handler.java:105)
E/AndroidRuntime( 5453):    at android.os.Looper.loop(Looper.java:156)
E/AndroidRuntime( 5453):    at android.app.ActivityThread.main(ActivityThread.java:6517)
E/AndroidRuntime( 5453):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 5453):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
E/AndroidRuntime( 5453):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
E/AndroidRuntime( 5453): Caused by: java.lang.SecurityException: Neither user 10470 nor current process has android.permission.WAKE_LOCK.
E/AndroidRuntime( 5453):    at android.os.Parcel.readException(Parcel.java:1673)
E/AndroidRuntime( 5453):    at android.os.Parcel.readException(Parcel.java:1626)
E/AndroidRuntime( 5453):    at android.os.IPowerManager$Stub$Proxy.acquireWakeLock(IPowerManager.java:572)
E/AndroidRuntime( 5453):    at android.os.PowerManager$WakeLock.acquireLocked(PowerManager.java:1399)
E/AndroidRuntime( 5453):    at android.os.PowerManager$WakeLock.acquire(PowerManager.java:1383)
E/AndroidRuntime( 5453):    at android.support.v4.app.JobIntentService$CompatWorkEnqueuer.enqueueWork(JobIntentService.java:191)
E/AndroidRuntime( 5453):    at android.support.v4.app.JobIntentService.enqueueWork(JobIntentService.java:522)
E/AndroidRuntime( 5453):    at android.support.v4.app.JobIntentService.enqueueWork(JobIntentService.java:500)
E/AndroidRuntime( 5453):    at io.flutter.plugins.geofencing.GeofencingService$Companion.enqueueWork(GeofencingService.kt:48)
E/AndroidRuntime( 5453):    at io.flutter.plugins.geofencing.GeofencingBroadcastReceiver.onReceive(GeofencingBroadcastReceiver.kt:20)
E/AndroidRuntime( 5453):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:3177)
E/AndroidRuntime( 5453):    ... 8 more

When trying it on an emulator I get https://github.com/bkonyi/FlutterGeofencing/issues/8#issue-405304944 instead, so the app can be run on neither for me.

magnus-lpa commented 5 years ago

Adding

<uses-permission android:name="android.permission.WAKE_LOCK" />

to AndroidManifest.xml seems to solve this issue in my case, but how come it seems to work for others without that permission?

Also, now I get another error when pressing the "Register" button:

I/GeofencingPlugin(13430): Successfully added geofence
I/GeofencingService(13430): Starting GeofencingService...
E/flutter (13430): [ERROR:flutter/shell/common/shell.cc(178)] Dart Error: Unhandled exception:
E/flutter (13430): 'dart:isolate/runtime/libtimer_impl.dart': Failed assertion: line 433: '<optimized out>': is not true.
E/flutter (13430): #0      _AssertionError._doThrowNew (dart:core/runtime/liberrors_patch.dart:40:39)
E/flutter (13430): #1      _AssertionError._throwNew (dart:core/runtime/liberrors_patch.dart:36:5)
E/flutter (13430): #2      _Timer._cancelWakeup (dart:isolate/runtime/libtimer_impl.dart:433:12)
E/flutter (13430): #3      _Timer._notifyEventHandler (dart:isolate/runtime/libtimer_impl.dart:299:7)
E/flutter (13430): #4      _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:419:5)
E/flutter (13430): #5      _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter (13430): Fences: [mtv] Location (55.7039743, 13.1903389) Event: GeofenceEvent.exit
bkonyi commented 5 years ago

Should be fixed by https://github.com/bkonyi/FlutterGeofencing/pull/16. Sorry for the delay on this!

ABDERRAHMANE-OUALI commented 2 years ago

@magnus-lpa this exception seems to be cause crash to devices running android 12 and above