transistorsoft / cordova-background-geolocation-lt

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
http://www.transistorsoft.com/shop/products/cordova-background-geolocation
Other
655 stars 277 forks source link

A crash occurred on the targetAPI31 android app. #1348

Closed chos-agoop closed 1 year ago

chos-agoop commented 2 years ago

Your Environment

Expected Behavior

The plugin can work on Android 12 devices and targetAPI=31 application with no crash.

Actual Behavior

When the device is rebooted, a crash occurred. please review the debug log.

Steps to Reproduce

  1. run the plugin with targetApi=31 app.
  2. don't permit the ACTIVITY_RECOGNITION permission(com.google.android.gms.permission.ACTIVITY_RECOGNITION)
  3. reboot the devices.
  4. the crash occurred in the console logs.

Context

We are trying to put the plugin to our app, the target api of our android app is 31 and the app doesn't own the ACTIVITY_RECOGNITION permission. By the way, I think the crash is from (https://github.com/nishkarsh/android-permissions), we also tried to update the library version, it still occurred the crash when the plugin is installed at first, we think it need be fixed inside the Plugin.

Debug logs

2022-04-28 17:45:45.185 10465-10504/jp.co.test.com.example D/TSLocationManager: [c.t.locationmanager.util.c h] ℹ️ LocationAuthorization: Permission granted 2022-04-28 17:45:45.185 10465-10504/jp.co.test.com.example I/TSLocationManager: [c.t.l.service.HeartbeatService b] 🎾 Start heartbeat (60s) 2022-04-28 17:45:45.193 10465-10465/jp.co.test.com.example D/TSLocationManager: [c.t.l.a.BackgroundGeolocation isMainActivityActive] NO 2022-04-28 17:45:45.209 10465-10465/jp.co.test.com.example D/AndroidRuntime: Shutting down VM 2022-04-28 17:45:45.212 10465-10465/jp.co.test.com.example E/AndroidRuntime: FATAL EXCEPTION: main Process: jp.co.test.com.example, PID: 10465 java.lang.IllegalArgumentException: jp.co.test.com.example: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. at android.app.PendingIntent.checkFlags(PendingIntent.java:378) at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:648) at android.app.PendingIntent.getBroadcast(PendingIntent.java:635) at com.intentfilter.androidpermissions.PermissionManager.notificationDismissIntent(PermissionManager.java:103) at com.intentfilter.androidpermissions.PermissionManager.showPermissionNotification(PermissionManager.java:69) at com.intentfilter.androidpermissions.PermissionHandler.requestPermissions(PermissionHandler.java:72) at com.intentfilter.androidpermissions.PermissionHandler.checkPermissions(PermissionHandler.java:47) at com.intentfilter.androidpermissions.PermissionManager.checkPermissions(PermissionManager.java:50) at com.transistorsoft.locationmanager.util.c$i.run(Unknown Source:15) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:8064) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1026) ``` PASTE_YOUR_LOGS_HERE ```
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

leoboyanu commented 1 year ago

Same issue happening with us, Any solution found?

leoboyanu commented 1 year ago

Facing below error while accessing location:

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. at android.app.PendingIntent.checkFlags(PendingIntent.java:375) at android.app.PendingIntent.buildServicePendingIntent(PendingIntent.java:724) at android.app.PendingIntent.getForegroundService(PendingIntent.java:716) at com.transistorsoft.locationmanager.location.SingleLocationRequest.getPendingIntent(Unknown Source:47) at com.transistorsoft.locationmanager.location.SingleLocationRequest.startUpdatingLocation(Unknown Source:48) at com.transistorsoft.locationmanager.location.SingleLocationRequest$a.onPermissionGranted(Unknown Source:36) at com.transistorsoft.locationmanager.util.c$i.onPermissionGranted(Unknown Source:41) at com.intentfilter.androidpermissions.PermissionHandler.checkPermissions(PermissionHandler.java:41) at com.intentfilter.androidpermissions.PermissionManager.checkPermissions(PermissionManager.java:50) at com.transistorsoft.locationmanager.util.c$g.run(Unknown Source:31) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:233) at android.os.Looper.loop(Looper.java:334) at android.app.ActivityThread.main(ActivityThread.java:8513) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)

christocracy commented 1 year ago

Yes, and what version of the plugin are you using?

leoboyanu commented 1 year ago

Our purchased license is for - cordova-background-geolocation - 3.9.4

christocracy commented 1 year ago

That is your problem. Go look at the CHANGELOG here in this repo and upgrade your plugin version to latest.

3.9.4 was released two years ago, before api 31 existed.