Alarmio
Alarmio copied to clipboard
IllegalStateException - unable to start TimerService
More background / Android O issues, yay!
The app was working fine on an emulator before the release, though; I'm guessing this is dependent on actually starting a timer, or some other condition that slipped through my tests... either way, this will probably need to be rewritten to prevent background restrictions from interfering with it.
java.lang.RuntimeException: Unable to create application me.jfenn.alarmio.Alarmio: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=me.jfenn.alarmio/.services.TimerService }: app is in background uid UidRecord{3f52aa u0a175 RCVR idle change:idle|uncached procs:1 seq(0,0,0)}
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5925)
at android.app.ActivityThread.access$1100(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=me.jfenn.alarmio/.services.TimerService }: app is in background uid UidRecord{3f52aa u0a175 RCVR idle change:idle|uncached procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1577)
at android.app.ContextImpl.startService(ContextImpl.java:1532)
at android.content.ContextWrapper.startService(ContextWrapper.java:664)
at me.jfenn.alarmio.Alarmio.onCreate(Alarmio.java:118)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1154)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5920)
... 8 more
As a workaround on my local fork. For snoozing, I've edited the alarm to the new time and set it to be enabled, but I don't think that is an optional solution for production.
Are all timers broken?
Hi @fennifith,
I just found I'm getting a similar issue in Android 9 on Nokia 8, but it doesn't look exactly the same. "java.lang.IndexOutofBoundsException at AlarmsAdapter.kt:450"
I'll post my stack trace separately.
Cheers 🙂
This is the error I was having when I clicked snooze
@madb1lly @ajayyy I believe you're describing #98? This error specifically has to do with background restrictions, and only occurs in the Application class (I believe Alarmio.onCreate
is being called with an active timer, without the app being in the foreground - causing the system to prevent it from starting the TimerService
and throwing this exception)
In terms of fixing this issue... I could just start the timer service only once an activity is started (that way it's ensured to be in the foreground and shouldn't crash). IIRC, the TimerService
is pretty non-essential; it isn't in charge of actually launching the timer, only displaying its progress in a notification.
Hi @fennifith, Yes I was hasty in posting against this issue, it is not the same. However I'm not exactly sure it's the same as #98 either, so I'll check and if necessary open a new issue. Cheers 🙂
Hi again @fennifith, I did actually get this error. It occurred on two occasions so far:
- When snoozing an alarm (first time that alarm had been used)
- Before a new alarm sounded
On Nokia 8 Android 9 stock.
Stack trace:
java.lang.RuntimeException: Unable to create application me.jfenn.alarmio.Alarmio: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=me.jfenn.alarmio/.services.TimerService }: app is in background uid UidRecord{5b6d31a u0a254 TPSL idle procs:1 seq(0,0,0)}
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5923)
at android.app.ActivityThread.access$1100(ActivityThread.java:202)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1665)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:6729)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876)
Caused by: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=me.jfenn.alarmio/.services.TimerService }: app is in background uid UidRecord{5b6d31a u0a254 TPSL idle procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1589)
at android.app.ContextImpl.startService(ContextImpl.java:1544)
at android.content.ContextWrapper.startService(ContextWrapper.java:664)
at me.jfenn.alarmio.Alarmio.onCreate(Alarmio.java:118)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1155)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5918)
... 8 more
Again
java.lang.RuntimeException at Alarmio.java:118
java.lang.RuntimeException
java.lang.RuntimeException: Unable to create application me.jfenn.alarmio.Alarmio: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=me.jfenn.alarmio/.services.TimerService }: app is in background uid UidRecord{c0eb220 u0a386 RCVR idle change:uncached procs:1 seq(0,0,0)}
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6898)
at android.app.ActivityThread.access$1600(ActivityThread.java:252)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:238)
at android.app.ActivityThread.main(ActivityThread.java:7878)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:512)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1028)
Caused by: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=me.jfenn.alarmio/.services.TimerService }: app is in background uid UidRecord{c0eb220 u0a386 RCVR idle change:uncached procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1674)
at android.app.ContextImpl.startService(ContextImpl.java:1609)
at android.content.ContextWrapper.startService(ContextWrapper.java:680)
at me.jfenn.alarmio.Alarmio.onCreate(Alarmio.java:118)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1189)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6893)
... 8 more
Android Version: 29
Device Manufacturer: realme
Device Model: RMX2111
I'm seeing the same error, reliably on phone startup:
java.lang.RuntimeException: Unable to create application me.jfenn.alarmio.Alarmio: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=me.jfenn.alarmio/.services.TimerService }: app is in background uid UidRecord{5663cf1 u0a32 RCVR idle change:uncached procs:1 seq(0,0,0)}
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6505)
at android.app.ActivityThread.access$1300(ActivityThread.java:225)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1865)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:359)
at android.app.ActivityThread.main(ActivityThread.java:7418)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
Caused by: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=me.jfenn.alarmio/.services.TimerService }: app is in background uid UidRecord{5663cf1 u0a32 RCVR idle change:uncached procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1616)
at android.app.ContextImpl.startService(ContextImpl.java:1571)
at android.content.ContextWrapper.startService(ContextWrapper.java:669)
at me.jfenn.alarmio.Alarmio.onCreate(Alarmio.java:118)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1190)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6500)
... 8 more
This is on Alarmio 1.0.5 from F-Droid, Android version 10 (build 52.1.A.3.49). This worked before for years.
When downgrading to 1.0.4 the problem didn't appear. Upgrading to 1.0.5 again I got the popup telling me to enable 'overlay access' (I don't think I had that enabled before). Restarting the phone didn't immediately make the problem re-appear - hopefully that did it :crossed_fingers: