Android分析服务Intent在Android Oreo上崩溃

时间:2017-09-17 08:22:54

标签: android google-analytics android-8.0-oreo

我已将我的应用升级为支持SDK 26,现在Google Analytics会在Android Oreo上运行时导致崩溃:

  

致命异常:java.lang.RuntimeException:无法启动接收器   com.google.android.gms.analytics.AnalyticsReceiver:   java.lang.IllegalStateException:不允许启动服务Intent {   ACT = com.google.android.gms.analytics.ANALYTICS_DISPATCH   CMP = com.example.android / com.google.android.gms.analytics.AnalyticsService   }:app在后台uid UidRecord {3f302e5 u0a107 RCVR idle procs:1   SEQ(0,0,0)}          在android.app.ActivityThread.handleReceiver(ActivityThread.java:3259)          在android.app.ActivityThread.-wrap17(未知来源)          在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)          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)由java.lang.IllegalStateException引起:不允许启动   服务意图{   ACT = com.google.android.gms.analytics.ANALYTICS_DISPATCH   CMP = com.example.android / com.google.android.gms.analytics.AnalyticsService   }:app在后台uid UidRecord {3f302e5 u0a107 RCVR idle procs:1   SEQ(0,0,0)}          在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.google.android.gms.internal.zzaot.onReceive(未知来源:68)          在com.google.android.gms.analytics.AnalyticsReceiver.onReceive(未知   来源:11)          在android.app.ActivityThread.handleReceiver(ActivityThread.java:3252)          在android.app.ActivityThread.-wrap17(未知来源)          在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)

这是我的相关文件:

<meta-data
    android:name="com.google.android.gms.analytics.globalConfigResource"
    android:resource="@xml/analytics"/>
<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version"/>

<!-- Optionally, register AnalyticsReceiver and AnalyticsService to support background
     dispatching on non-Google Play devices -->
<receiver
    android:name="com.google.android.gms.analytics.AnalyticsReceiver"
    android:enabled="true">
    <intent-filter>
        <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH"/>
    </intent-filter>
</receiver>
<service
    android:name="com.google.android.gms.analytics.AnalyticsService"
    android:enabled="true"
    android:exported="false"/>

<!-- Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable
     installation campaign reporting -->
<receiver
    android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
    android:exported="true">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER"/>
    </intent-filter>
</receiver>
<service
    android:name="com.google.android.gms.analytics.CampaignTrackingService"
    android:exported="true"/>

过去24小时内有数百台Oreo设备因此而崩溃。似乎仅在安装时受到影响。我将尝试添加android:permission =&#34; android.permission.BIND_JOB_SERVICE&#34;到2分析服务,看看。会报告。

如果需要,我很乐意提供更多信息。感谢

2 个答案:

答案 0 :(得分:13)

我建议升级到播放服务版本11.4.0。将其添加到Gradle文件中:

compile "com.google.android.gms:play-services-analytics:11.4.0

来自Play Services Revision 11.4.0,分析部分:

  • 添加了新课程AnalyticsJobService。此类为Android O提供兼容性支持,并由Analytics用于上传数据。使用此类不需要任何操作,它会自动添加为Analytics包的一部分。
  • 弃用了getContext()类的AnalyticsService方法。
  • 弃用CampaignTrackingService类。

而且你必须获得许可。 android:permission =“android.permission.BIND_JOB_SERVICE”

见下文 https://developers.google.com/android/reference/com/google/android/gms/analytics/AnalyticsJobService

答案 1 :(得分:2)

因为CampaignTrackingService现已弃用

从清单中删除此行

<service android:name="com.google.android.gms.analytics.CampaignTrackingService"
         android:exported="true"/>