title: Google Analytics service Intent crashes on Android Oreo
body: <p>I have upgraded my app to support SDK 26 and now Google Analytics causes crashes when running on Android Oreo:</p>
  
  <blockquote>
    <p>Fatal Exception: java.lang.RuntimeException: Unable to start receiver
    com.google.android.gms.analytics.AnalyticsReceiver:
    java.lang.IllegalStateException: Not allowed to start service Intent {
    act=com.google.android.gms.analytics.ANALYTICS_DISPATCH
    cmp=com.example.android/com.google.android.gms.analytics.AnalyticsService
    }: app is in background uid UidRecord{3f302e5 u0a107 RCVR idle procs:1
    seq(0,0,0)}
           at android.app.ActivityThread.handleReceiver(ActivityThread.java:3259)
           at android.app.ActivityThread.-wrap17(Unknown Source)
           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677)
           at android.os.Handler.dispatchMessage(Handler.java:105)
           at android.os.Looper.loop(Looper.java:164)
           at android.app.ActivityThread.main(ActivityThread.java:6541)
           at java.lang.reflect.Method.invoke(Method.java)
           at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) Caused by java.lang.IllegalStateException: Not allowed to start
    service Intent {
    act=com.google.android.gms.analytics.ANALYTICS_DISPATCH
    cmp=com.example.android/com.google.android.gms.analytics.AnalyticsService
    }: app is in background uid UidRecord{3f302e5 u0a107 RCVR idle procs:1
    seq(0,0,0)}
           at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1505)
           at android.app.ContextImpl.startService(ContextImpl.java:1461)
           at android.content.ContextWrapper.startService(ContextWrapper.java:644)
           at android.content.ContextWrapper.startService(ContextWrapper.java:644)
           at com.google.android.gms.internal.zzaot.onReceive(Unknown Source:68)
           at com.google.android.gms.analytics.AnalyticsReceiver.onReceive(Unknown
    Source:11)
           at android.app.ActivityThread.handleReceiver(ActivityThread.java:3252)
           at android.app.ActivityThread.-wrap17(Unknown Source)
           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677)
           at android.os.Handler.dispatchMessage(Handler.java:105)
           at android.os.Looper.loop(Looper.java:164)
           at android.app.ActivityThread.main(ActivityThread.java:6541)
           at java.lang.reflect.Method.invoke(Method.java)
           at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)</p>
  </blockquote>
  
  <p>This is my relevant Manifest:</p>
  
  <pre><code>&lt;meta-data
      android:name="com.google.android.gms.analytics.globalConfigResource"
      android:resource="@xml/analytics"/&gt;
  &lt;meta-data
      android:name="com.google.android.gms.version"
      android:value="@integer/google_play_services_version"/&gt;
  
  &lt;!-- Optionally, register AnalyticsReceiver and AnalyticsService to support background
       dispatching on non-Google Play devices --&gt;
  &lt;receiver
      android:name="com.google.android.gms.analytics.AnalyticsReceiver"
      android:enabled="true"&gt;
      &lt;intent-filter&gt;
          &lt;action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH"/&gt;
      &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  &lt;service
      android:name="com.google.android.gms.analytics.AnalyticsService"
      android:enabled="true"
      android:exported="false"/&gt;
  
  &lt;!-- Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable
       installation campaign reporting --&gt;
  &lt;receiver
      android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
      android:exported="true"&gt;
      &lt;intent-filter&gt;
          &lt;action android:name="com.android.vending.INSTALL_REFERRER"/&gt;
      &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  &lt;service
      android:name="com.google.android.gms.analytics.CampaignTrackingService"
      android:exported="true"/&gt;
  </code></pre>
  
  <p>Having hundreds of Oreo devices crashing due to this in past 24 hours. Seems to be affecting only on install. I am going to try and add android:permission="android.permission.BIND_JOB_SERVICE" to the 2 analytics services and see. Will report. </p>
  
  <p>I Will be happy to provide more info if needed. Thanks</p>