Open andkom opened 2 years ago
Having the same issue in SDK 31.
I have forked and released a new version of this library with fixes for android 12 issues https://www.npmjs.com/package/@hariks789/react-native-background-geolocation Let me know if this fixes your issue
@hariks789 tried you fix but having other issues, now both on android 10 - 11 and android 12.
Android 12 IllegalArgumentException pending intent must be mutable
com.android.internal.util.Preconditions in checkArgument at line 59 android.location.LocationManager in addProximityAlert at line 2194 com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider in startMonitoringStationaryRegion at line 368 com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider in onLocationChanged at line 299 android.location.LocationListener in onLocationChanged at line 63 android.location.LocationManager$LocationListenerTransport$1 in operate at line 3180 android.location.LocationManager$LocationListenerTransport$1 in operate at line 3177 com.android.internal.listeners.ListenerExecutor in lambda$executeSafely$0 at line 127 com.android.internal.listeners.ListenerExecutor$$ExternalSyntheticLambda0 in run at line 8 android.os.Handler in handleCallback at line 938 android.os.Handler in dispatchMessage at line 99 android.os.Looper in loopOnce at line 210 android.os.Looper in loop at line 299 android.app.ActivityThread in main at line 8085 java.lang.reflect.Method in invoke com.android.internal.os.RuntimeInit$MethodAndArgsCaller in run at line 556 com.android.internal.os.ZygoteInit in main at line 1045
Android 10 - 11 RuntimeException Error receiving broadcast Intent { act=com.tenforwardconsulting.cordova.bgloc.SINGLE_LOCATION_UPDATE_ACTION flg=0x10 } in com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider$1@c90d10c
android.app.LoadedApk$ReceiverDispatcher$Args in lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args at line 1590 android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA in run at line 2 android.os.Handler in handleCallback at line 938 android.os.Handler in dispatchMessage at line 99 android.os.Looper in loop at line 236 android.os.HandlerThread in run at line 67
NullPointerException Attempt to invoke virtual method 'java.lang.Object android.os.Bundle.get(java.lang.String)' on a null object reference
com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider$1 in onReceive at line 450 android.app.LoadedApk$ReceiverDispatcher$Args in lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args at line 1580 android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA in run at line 2 android.os.Handler in handleCallback at line 938 android.os.Handler in dispatchMessage at line 99 android.os.Looper in loop at line 236 android.os.HandlerThread in run at line 67
@michelevettone Which package version are you using now? I have added a fix for pending intent must be mutable in version 0.7.1. Let me know if that one fixes the first issue
For Android 10-11 issues, is there a way to reproduce them
I have enabled Issues sections on my fork for discussing this further
I have forked and released a new version of this library with fixes for android 12 issues https://www.npmjs.com/package/@hariks789/react-native-background-geolocation Let me know if this fixes your issue
I got an error on this
stationaryAlarmPI = PendingIntent.getBroadcast(mContext, 0, new Intent(STATIONARY_ALARM_ACTION), PendingIntent.FLAG_MUTABLE );
@gomezmark Can you please create an issue on the forked repo with some sample code you use and steps to reproduce this? I will take look into that
https://github.com/hariks789/react-native-background-geolocation/issues
For me on Android 12 the app doesn't crash but the plugin doesn't work in the background mode as in target =<30
For me on Android 12 the app doesn't crash but the plugin doesn't work in the background mode as in target =<30
me too same issue
Your Environment
Context
When app switch to background, I start background location service to receive location updates in the background. In Android 9,10,11 all worked perfectly. After upgrade to SDK 31, background location service does not work, app crashes in backround.
Expected Behavior
Background service starts and run successfully in app with targetSdkVersion = 31
Actual Behavior
Background service does not start, app crashed in background:
Possible Fix
Modify https://github.com/mauron85/background-geolocation-android/blob/58464febf6901f1e489817e4425418d48443929b/src/main/java/com/marianhello/bgloc/sync/NotificationHelper.java#L77 and add FLAG_IMMUTABLE
Steps to Reproduce
Context
Debug logs