IllegalStateException: Not allowed to start service in background
Closed this issue · 5 comments
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- My Android device/devices supports BLE and has Android OS version >= 4.4
- My Android device/devices have Bluetooth enabled
- My app has Location Permissions granted
Basic information
Estimote SDK version: 1.4.1
Android devices affected: Galaxy S8
Android OS version affected: Android 8.0
Beacon hardware version: Will check tomorrow
Description
Got this crash from Crashlytics in the wild, can't reproduce it myself. But this is a well known change for Android Oreo, where you can no longer start services from background. Read more here. My app targets API 27.
Expected behavior: not to crash
Actual behavior: crashes
Logs and code
Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.estimote.coresdk.scanning.scheduling.SystemAlarmManager$AlarmBroadcastReceiver: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=com.coke.tastly/com.estimote.coresdk.service.BeaconService }: app is in background uid UidRecord{fd37547 u0a189 RCVR bg:+1m0s285ms idle procs:1 seq(36,36,36)}
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3397)
at android.app.ActivityThread.-wrap18(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1780)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
I am also seeing this crash popup from some users. Huawei and Samsung devices.
Is there any ETA for the fix?
Hello,
i'm facing the same issue, any resolution on this ?
Hello guys,
This problem affects phones with Android 8.0+ I suppose. This SDK is no longer being maintained, thus there is no support for Oreo+ phones in it. I really encourage you to switch to our currently being developed ProximitySDK 🚀 - it supports all Android devices since 5.0, and is well prepared for background-work changes introduced in Android 8.0. Plus the API is way easier to use and lets you avoid many common mistakes - such as wrong states, or BLE errors. :)
Regards,
Paweł
[Cleaning up stale issues following the rebranding of Estimote SDK to Estimote Fleet Management SDK]
As Pawel mentioned, for proximity detection (enter/exit events), we're asking developers to migrate to our Proximity SDK:
https://developer.estimote.com/proximity/android-tutorial/
If you need any help with the migration, let us know on our forums: