background_locator_fixed icon indicating copy to clipboard operation
background_locator_fixed copied to clipboard

App being crashed: yukams.app.background_locator_2.IsolateHolderService.getNotification

Open thebeliever18 opened this issue 6 months ago • 4 comments

Hello,

In flutter, I have used workmanager and background_locator_2 and stored location co-ordinates in sharedpreference workmanager calls function of background_locator_2 in every 15 mins background_locator_2 stores the location co-ordinates in every 5 mins when app is terminated both workmanager and background_locator_2 both of them are working properly. But after some days My app is being crashed and sending reports as: yukams.app.background_locator_2.IsolateHolderService.getNotification java.lang.IllegalArgumentException Exception java.lang.RuntimeException: at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4804) at android.app.ActivityThread.-$$Nest$mhandleServiceArgs at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2266) at android.os.Handler.dispatchMessage (Handler.java:106) at android.os.Looper.loopOnce (Looper.java:201) at android.os.Looper.loop (Looper.java:288) at android.app.ActivityThread.main (ActivityThread.java:8061) at java.lang.reflect.Method.invoke at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:703) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:923) Caused by java.lang.IllegalArgumentException: at android.os.Parcel.createExceptionOrNull (Parcel.java:3021) at android.os.Parcel.createException (Parcel.java:3001) at android.os.Parcel.readException (Parcel.java:2984) at android.os.Parcel.readException (Parcel.java:2926) at android.app.INotificationManager$Stub$Proxy.createNotificationChannels (INotificationManager.java:3563) at android.app.NotificationManager.createNotificationChannels (NotificationManager.java:935) at android.app.NotificationManager.createNotificationChannel (NotificationManager.java:923) at yukams.app.background_locator_2.IsolateHolderService.getNotification (IsolateHolderService.java) at yukams.app.background_locator_2.IsolateHolderService.start (IsolateHolderService.java) at yukams.app.background_locator_2.IsolateHolderService.startHolderService (IsolateHolderService.java) at yukams.app.background_locator_2.IsolateHolderService.onStartCommand (IsolateHolderService.java) at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4786)

This error is mostly occuring in android version 11,12 and 13. Please provide the solution. Thanks

thebeliever18 avatar Feb 04 '24 05:02 thebeliever18

Are you sure that app notification permission is granted?

ramazancopur avatar Feb 06 '24 10:02 ramazancopur

Hello, @ramazancopur thanks for replying. Yes I have added notification permission. In this way.

FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
      FlutterLocalNotificationsPlugin();
  flutterLocalNotificationsPlugin
      .resolvePlatformSpecificImplementation<
          AndroidFlutterLocalNotificationsPlugin>()
      ?.requestPermission();

requestPermission() here asks for the permission.

For Android 13 and higher we now need to add.

<manifest ...>
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    <application ...>
        ...
    </application>
</manifest>

According to official android documentation: (https://developer.android.com/develop/ui/views/notifications/notification-permission), which I had not added earlier, but after seeing your comment I reviewed my code and added POST_NOTIFICATIONS permission in my AndroidManifest.xml file for Android 13 and higher.

For the versions below Android 13 requestPermission() is working fine.

I have uploaded the app in play store after adding POST_NOTIFICATIONS permission, will check the data of firebase crashlytics and will notify you soon.

Your comment was really helpful. Thanks,

thebeliever18 avatar Feb 07 '24 09:02 thebeliever18

@thebeliever18 Did POST_NOTIFICATIONS permission resolve your issue?

ranahyder87 avatar Feb 25 '24 10:02 ranahyder87

The same issue I have, resolved it?

rodrideveloper avatar Apr 24 '24 14:04 rodrideveloper