What happened?
Google Play reports a production crash when LightningNodeService is created and calls startForeground() in onCreate.
Cause from stack:
android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground service type dataSync
Exception java.lang.RuntimeException:
at android.app.ActivityThread.handleCreateService (ActivityThread.java:5929)
...
Caused by android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground service type dataSync
...
at android.app.Service.startForeground (Service.java:776)
at to.bitkit.androidServices.LightningNodeService.onCreate (LightningNodeService.kt:64)
at android.app.ActivityThread.handleCreateService (ActivityThread.java:5916)
- Service type in manifest:
foregroundServiceType="dataSync".
- On Android 15+ (API 35+),
dataSync foreground services are limited to 6 hours total per 24-hour window; after that, starting another dataSync FGS throws this exception.
- Started from
MainActivity via LaunchedEffect when wallet exists and notifications are granted → startForegroundService(LightningNodeService).
- Service uses
START_STICKY — system may recreate the service after kill.
- Play Vitals (60-day): ~23% of top crash events (~36 events, ~14 users); mostly version 181 (2.2.0); Android 15/16 only; mostly foreground.
Expected behavior
App must not crash when the user opens Bitkit or the system restarts LightningNodeService after the dataSync FGS time budget is exhausted. Defer FGS start until allowed, use WakeNodeWorker where appropriate, or comply with Android 15+ dataSync limits.
Steps to Reproduce
- Android 15 or 16 device, mainnet wallet, notifications on.
- Keep
LightningNodeService running in background until dataSync 6h / 24h budget is exhausted.
- Open app —
MainActivity starts service → crash in onCreate at startForeground.
- Alternate:
START_STICKY restart while quota exhausted.
- Logcat: confirm
Time limit already exhausted for foreground service type dataSync.
Related repro: may follow #980 (slow teardown after onTimeout).
Logs / Screenshots / Recordings
Exception java.lang.RuntimeException:
at android.app.ActivityThread.handleCreateService (ActivityThread.java:5929)
at android.app.ActivityThread.-$$Nest$mhandleCreateService (Unknown Source)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2924)
at android.os.Handler.dispatchMessage (Handler.java:110)
at android.os.Looper.loopOnce (Looper.java:273)
at android.os.Looper.loop (Looper.java:363)
at android.app.ActivityThread.main (ActivityThread.java:10060)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:632)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:975)
Caused by android.app.ForegroundServiceStartNotAllowedException: Time limit already exhausted for foreground service type dataSync
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:5229)
at android.os.Parcel.readParcelable (Parcel.java:5211)
at android.os.Parcel.createExceptionOrNull (Parcel.java:3349)
at android.os.Parcel.createException (Parcel.java:3338)
at android.os.Parcel.readException (Parcel.java:3321)
at android.os.Parcel.readException (Parcel.java:3263)
at android.app.IActivityManager$Stub$Proxy.setServiceForeground (IActivityManager.java:7539)
at android.app.Service.startForeground (Service.java:776)
at to.bitkit.androidServices.LightningNodeService.onCreate (LightningNodeService.kt:64)
at android.app.ActivityThread.handleCreateService (ActivityThread.java:5916)
Play Console: Vitals → ForegroundServiceStartNotAllowedException → LightningNodeService.onCreate.
Play report: https://play.google.com/console/u/1/developers/5690237613698939049/app/4973032799696771282/vitals/crashes/7cb781591f83cb407a22509c31455ef9/details?isUserPerceived=true&days=60
Bitkit Version
2.2.0 (version code 181), mainnet to.bitkit. Shipped tag v2.2.0 (2026-04-07), targetSdk = 36.
Device / OS
Android 15 (SDK 35), Android 16 Beta (SDK 36). Example devices: Samsung A16, A17x, PA3Q, others.
Reproducibility
Sometimes (<50%)
Additional context
Likely chain with #980: long-running dataSync FGS → onTimeout → slow stop → quota issues → restart/open app → this crash.
Suggested fix: do not call startForeground unconditionally in onCreate on API 35+ without checking allowance; fix onTimeout/stop paths in #980; revisit START_STICKY and architecture (#443).
References:
What happened?
Google Play reports a production crash when
LightningNodeServiceis created and callsstartForeground()inonCreate.Cause from stack:
foregroundServiceType="dataSync".dataSyncforeground services are limited to 6 hours total per 24-hour window; after that, starting anotherdataSyncFGS throws this exception.MainActivityviaLaunchedEffectwhen wallet exists and notifications are granted →startForegroundService(LightningNodeService).START_STICKY— system may recreate the service after kill.Expected behavior
App must not crash when the user opens Bitkit or the system restarts
LightningNodeServiceafter thedataSyncFGS time budget is exhausted. Defer FGS start until allowed, useWakeNodeWorkerwhere appropriate, or comply with Android 15+dataSynclimits.Steps to Reproduce
LightningNodeServicerunning in background untildataSync6h / 24h budget is exhausted.MainActivitystarts service → crash inonCreateatstartForeground.START_STICKYrestart while quota exhausted.Time limit already exhausted for foreground service type dataSync.Related repro: may follow #980 (slow teardown after
onTimeout).Logs / Screenshots / Recordings
Play Console: Vitals →
ForegroundServiceStartNotAllowedException→LightningNodeService.onCreate.Play report: https://play.google.com/console/u/1/developers/5690237613698939049/app/4973032799696771282/vitals/crashes/7cb781591f83cb407a22509c31455ef9/details?isUserPerceived=true&days=60
Bitkit Version
2.2.0 (version code 181), mainnet
to.bitkit. Shipped tagv2.2.0(2026-04-07),targetSdk = 36.Device / OS
Android 15 (SDK 35), Android 16 Beta (SDK 36). Example devices: Samsung A16, A17x, PA3Q, others.
Reproducibility
Sometimes (<50%)
Additional context
Likely chain with #980: long-running
dataSyncFGS →onTimeout→ slow stop → quota issues → restart/open app → this crash.Suggested fix: do not call
startForegroundunconditionally inonCreateon API 35+ without checking allowance; fixonTimeout/stop paths in #980; revisitSTART_STICKYand architecture (#443).References: