我已经提到了以下解决方案: Google Analytics service Intent crashes on Android Oreo
但仍然面临问题。
Fatal Exception: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.google.android.gms.analytics.ANALYTICS_DISPATCH cmp=com.androidapp/com.google.android.gms.analytics.AnalyticsService }: app is in background uid UidRecord{cff6737 u0a196 LAST bg:+3m17s940ms idle change:cached procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1522)
at android.app.ContextImpl.startService(ContextImpl.java:1478)
at android.content.ContextWrapper.startService(ContextWrapper.java:651)
at cqg.c(Unknown Source:36)
在将GCM更改为FCM之前: 我们正在使用-编译“ com.google.android.gms:play-services-analytics:10.2.1”
我们使用的新版本是- 编译'com.google.android.gms:play-services-analytics:16.0.4'
build.gradle-
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:support-v13:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.google.maps:google-maps-services:0.2.6'
// compile 'com.google.android.gms:play-services-maps:7.3.0'
compile 'com.google.android.gms:play-services-location:16.0.0'
compile 'com.google.android.gms:play-services-places:16.0.0'
//compile 'com.google.android.gms:play-services-gcm:15.0.1'
compile "com.google.firebase:firebase-messaging:17.3.3"
compile 'com.google.firebase:firebase-core:16.0.4'
compile 'com.google.android.gms:play-services-maps:16.0.0'
compile 'com.google.code.gson:gson:2.4'
compile 'com.mcxiaoke.volley:library:1.0.18'
compile 'com.facebook.android:facebook-android-sdk:4.35.0'
compile 'commons-lang:commons-lang:2.6'
//compile files('libs/jackson-all-1.9.11.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/quickridedomainmodel-0.0.1-SNAPSHOT.jar')
compile files('libs/restclient-0.0.1-SNAPSHOT.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.2.2@aar')
AndroidManifest.xml
<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" />
<receiver
android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:exported="true"
android:enabled="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="false"
android:enabled="true"/>
<receiver
android:name="com.androidapp.startup.InstallReferrerReceiver"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service
android:name="com.androidapp.notification.QuickRideInstanceIDService">
<!--android:exported="false">-->
<intent-filter>
<!--<action android:name="com.google.android.gms.iid.InstanceID" />-->
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>