gpt4 book ai didi

android - Google Analytics 服务 Intent 在 Android Oreo 上崩溃

转载 作者:可可西里 更新时间:2023-11-01 18:46:11 28 4
gpt4 key购买 nike

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

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)

这是我的相关 list :

<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="android.permission.BIND_JOB_SERVICE"添加到 2 个分析服务并查看。会报。

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

最佳答案

我建议升级到 play-services 版本 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 包的一部分自动添加。
  • 弃用了 AnalyticsService 类的 getContext() 方法。
  • 弃用了 CampaignTrackingService 类。

而且您还必须获得许可。android:permission="android.permission.BIND_JOB_SERVICE"

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

关于android - Google Analytics 服务 Intent 在 Android Oreo 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46262082/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com