Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ForegroundServiceStartNotAllowedException Crash Despite Fallback Mechanism in v2.20.6 #1201

Open
pubudithajayasekara opened this issue Sep 11, 2024 · 3 comments

Comments

@pubudithajayasekara
Copy link

Issue Description

We are encountering a ForegroundServiceStartNotAllowedException in our application when using the org.altbeacon:android-beacon-library:2.20.6. According to the documentation, starting with library version 2.19.5-beta6, the library should handle this exception by falling back to using the Job Scheduler for scans when starting a foreground service is not allowed by the operating system. However, we are still experiencing crashes related to this issue.

Stack Trace

ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false ...

Expected Behavior

According to the documentation, the library should catch the ForegroundServiceStartNotAllowedException and use the Job Scheduler as a fallback, resuming the use of a foreground service when the app returns to the foreground.

Actual Behavior

Despite using version 2.20.6, the application is crashing due to the ForegroundServiceStartNotAllowedException, which suggests that the fallback mechanism to the Job Scheduler may not be working as intended.

Steps to Reproduce

  1. Integrate org.altbeacon:android-beacon-library:2.20.6 into the application.
  2. Attempt to start a foreground service while the app is in the background.
  3. Observe the crash related to ForegroundServiceStartNotAllowedException.

Additional Information

  • Android Version: 12+
  • Device Models: [Cricket U680AC , google Pixel 8 , motorola , OPPO CPH2385 , samsung SM-A045F, Nokia Nokia G11 Plus ....]
  • Library Version: org.altbeacon:android-beacon-library:2.20.6

Documentation Reference

@slai47
Copy link

slai47 commented Oct 14, 2024

Bumping this as this error is still occurring on 2.20.7.

Logs from Crashlytics from our production:

       at android.app.ActivityThread.handleCreateService(ActivityThread.java:4925)
       at android.app.ActivityThread.-$$Nest$mhandleCreateService()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2407)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loopOnce(Looper.java:232)
       at android.os.Looper.loop(Looper.java:317)
       at android.app.ActivityThread.main(ActivityThread.java:8592)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
       at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
       at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
       at android.os.Parcel.readParcelableInternal(Parcel.java:5016)
       at android.os.Parcel.readParcelable(Parcel.java:4998)
       at android.os.Parcel.createExceptionOrNull(Parcel.java:3178)
       at android.os.Parcel.createException(Parcel.java:3167)
       at android.os.Parcel.readException(Parcel.java:3150)
       at android.os.Parcel.readException(Parcel.java:3092)
       at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6960)
       at android.app.Service.startForeground(Service.java:776)
       at org.altbeacon.beacon.service.BeaconService.startForegroundIfConfigured(BeaconService.java:279)
       at org.altbeacon.beacon.service.BeaconService.onCreate(BeaconService.java:201)
       at android.app.ActivityThread.handleCreateService(ActivityThread.java:4912)
       at android.app.ActivityThread.-$$Nest$mhandleCreateService()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2407)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loopOnce(Looper.java:232)
       at android.os.Looper.loop(Looper.java:317)
       at android.app.ActivityThread.main(ActivityThread.java:8592)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)

Android Version 14 is only effected for us. Replication steps are the same as above.

Devices are Samsung and Google. S24, 23 Ultra, Pixel 8, 7 and 6 for examples.

Version 2.20.6 on production, 2.20.7 on staging. Both having similar issues.

@slai47
Copy link

slai47 commented Oct 14, 2024

Could this be related to https://issuetracker.google.com/issues/307329994 and needing to add in more permission settings with ServiceCompat?

@oebb
Copy link

oebb commented Nov 6, 2024

We're also having the same issue w Android 14 devices (targeting Android 14)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants