Skip to content

[Android O] IllegalStateException: Not allowed to start service Intent #729

Closed
@cre8ivejp

Description

@cre8ivejp

Hi,

From Android O, background tasks must call Context.startForegroundService instead of Context.startService ,but in this case you could just extend the PushService to JobIntentService to solve this.

Could you take a look at this issue please?

Migration guide:
https://developer.android.com/about/versions/oreo/android-8.0-changes.html#back-all

Model

Device: Google Pixel
OS: Android 8.0.0
SDK Version : 1.15.8

Error log

Fatal Exception: java.lang.RuntimeException
Unable to start receiver com.parse.GcmBroadcastReceiver: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTRATION flg=0x10 pkg=com.example.sample cmp=com.example.sample/com.parse.PushService (has extras) }: app is in background uid UidRecord{ac05be6 u0a187 TRNB idle procs:1 seq(0,0,0)}


Caused by java.lang.IllegalStateException
--
  | android.app.ContextImpl.startServiceCommon (ContextImpl.java:1505)
  | android.app.ContextImpl.startService (ContextImpl.java:1461)
  | android.content.ContextWrapper.startService (ContextWrapper.java:644)
  | android.content.ContextWrapper.startService (ContextWrapper.java:644)
  | com.parse.ServiceUtils.runIntentInService (ServiceUtils.java:37)
  | com.parse.ServiceUtils.runWakefulIntentInService (ServiceUtils.java:68)
  | com.parse.GcmBroadcastReceiver.onReceive (GcmBroadcastReceiver.java:23)
  | android.app.ActivityThread.handleReceiver (ActivityThread.java:3252)
  | android.app.ActivityThread.-wrap17 (Unknown Source)
  | android.app.ActivityThread$H.handleMessage (ActivityThread.java:1677)
  | android.os.Handler.dispatchMessage (Handler.java:105)
  | android.os.Looper.loop (Looper.java:164)
  | android.app.ActivityThread.main (ActivityThread.java:6541)
  | java.lang.reflect.Method.invoke (Method.java)
  | com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:240)
  | com.android.internal.os.ZygoteInit.main (ZygoteInit.java:767)


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions