xamarin / GooglePlayServicesComponents

Other
315 stars 148 forks source link

Google Analytics - IllegalStateException for Android 8.0 #149

Open david-laundav opened 6 years ago

david-laundav commented 6 years ago

Xamarin.Android Version (eg: 6.0):

8.0+

Operating System & Version (eg: Mac OSX 10.11):

N/A

Google Play Services Version (eg: 8.4.0):

NuGet: 60.1142.1

Describe your Issue:

We're getting lots of reported crashes from Android 8.0 devices for the Google Analytics library.

Others have mentioned that the solution is to upgrade, but there is no new update available for the Xamarin binding libraries.

Steps to Reproduce (with link to sample solution if possible):

N/A

Include any relevant Exception Stack traces, build logs, adb logs:

Stacktrace

Message: Not allowed to start service Intent { act=com.google.android.gms.analytics.ANALYTICS_DISPATCH cmp=com.juke.music/com.google.android.gms.analytics.AnalyticsService }: app is in background uid UidRecord{37d58a2 u0a191 CAC bg:+2m49s628ms idle procs:1 seq(0,0,0)}

System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in <1debb7d2bfca4e33ab12c39822d9046f>:0
Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod(Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method) in <6cae2c0eb1954862a58bb5dbaf9d1873>:0
Android.Runtime.JNIEnv.CallVoidMethod(System.IntPtr jobject, System.IntPtr jmethod) in <8981cd2235bb4213bc3eac73d6de42e6>:0
Android.Gms.Analytics.GoogleAnalytics.DispatchLocalHits() in <042dd70b7d474228a46ee47cd2d94a1d>:0
Music.Droid.Platform.GoogleTracker.OnConnectivityChanged(System.Object sender, System.EventArgs e) in <335971536168437c99fa3b72463e71ed>:0
E247.Apps.Music.Content.Connectivity.ConnectivityListenerBase.set_IsOnline(System.Boolean value) in <b4b9cf8f106247a9bddb104161b04396>:0
E247.Apps.Music.Content.Connectivity.ConnectivityListenerBase.UpdateConnectionAsync() in <b4b9cf8f106247a9bddb104161b04396>:0
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in <1debb7d2bfca4e33ab12c39822d9046f>:0
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task task) in <1debb7d2bfca4e33ab12c39822d9046f>:0
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task task) in <1debb7d2bfca4e33ab12c39822d9046f>:0
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task task) in <1debb7d2bfca4e33ab12c39822d9046f>:0
System.Runtime.CompilerServices.TaskAwaiter.GetResult() in <1debb7d2bfca4e33ab12c39822d9046f>:0

E247.Apps.Music.Content.Connectivity.ConnectivityListenerBase.OnConnectionChanged() in <b4b9cf8f106247a9bddb104161b04396>:0
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in <1debb7d2bfca4e33ab12c39822d9046f>:0
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0(System.Object state) in <1debb7d2bfca4e33ab12c39822d9046f>:0

Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0() in <8981cd2235bb4213bc3eac73d6de42e6>:0
Java.Lang.Thread+RunnableImplementor.Run() in <8981cd2235bb4213bc3eac73d6de42e6>:0
Java.Lang.IRunnableInvoker.n_Run(System.IntPtr jnienv, System.IntPtr native__this) in <8981cd2235bb4213bc3eac73d6de42e6>:0
background uid UidRecord{37d58a2 u0a191 CAC bg:+2m49s628ms idle procs:1 seq(0,0,0)}
android.app.ContextImpl.startServiceCommon in ContextImpl.java:1538
android.app.ContextImpl.startService in ContextImpl.java:1484
android.content.ContextWrapper.startService in ContextWrapper.java:663
com.google.android.gms.internal.zzamj.zzvs in Unknown Source:36
com.google.android.gms.analytics.GoogleAnalytics.dispatchLocalHits in Unknown Source:8
mono.java.lang.RunnableImplementor.n_run(Native Method):null
mono.java.lang.RunnableImplementor.run in RunnableImplementor.java:30
android.os.Handler.handleCallback in Handler.java:789
android.os.Handler.dispatchMessage in Handler.java:98
android.os.Looper.loop in Looper.java:164
android.app.ActivityThread.main in ActivityThread.java:6944
java.lang.reflect.Method.invoke(Native Method):null
com.android.internal.os.Zygote$MethodAndArgsCaller.run in Zygote.java:327
com.android.internal.os.ZygoteInit.main in ZygoteInit.java:1374

VS bug #732433

Redth commented 5 years ago

I'm not sure upgrading is going to help. It looks like some folks are suggesting 11.4.0 and we're already 11.4.2. Also another noting it's still an issue on 15.0.1.

This also leads me to believe it's a usage/configuration issue rather than a xamarin binding issue.

What does your final AndroidManifest.xml look like in your app?

david-laundav commented 5 years ago

Hi @Redth and @SotoiGhost,

As a note, on the 5th of September 2018, this was solved in the Android Library:

Spetember 5, 2018 Android Sender 16.0.2

Fixed the IllegalStateException thrown when ReconnectionService is started in background if the app targets to Android O or higher. Apps that enable reconnection service should update to use this version to avoid being affected this bug.

https://developers.google.com/cast/docs/release-notes#spetember-5-2018

This means that targeting the newest version of the Android SKD should help circumvent this issue.

Redth commented 5 years ago

Thanks, we're currently working on getting 15.x versions out, and after that we'll look at first updating this particular library to 16.0.2 where it appears to be fixed on Google's side.

gpandroid90 commented 5 years ago

we are getting this issue with version com.google.android.gms:play-services-analytics:16.0.6'

Redth commented 5 years ago

This sounds like an upstream bug and I'm not sure where it's fixed. Please give this a try once we get preview packages out for 16.0.2 or higher.

atuledate007 commented 5 years ago

CampaignTrackingService remove from manifest its depecreated

iBotasky commented 5 years ago

I am using com.google.android.gms:play-services-analytics:16.0.6 still occur this issue.

hamidsn commented 5 years ago

I am using com.google.android.gms:play-services-analytics:16.0.6 still occur this issue.

Same for me.

moljac commented 5 years ago

@iBotasky @hamidsn

Could you provide minimal repro sample, please?

Thanks

Wbreadboy commented 4 years ago

17.0.0 still occur this issue at 100% HUAWEI (Android 10)