appmetrica / appmetrica-sdk-android

AppMetrica SDK for Android
https://appmetrica.io
MIT License
53 stars 5 forks source link

java.lang.RuntimeException: Unable to bind to service io.appmetrica.analytics.internal.AppMetricaService #7

Closed E-D-W-I-N closed 3 weeks ago

E-D-W-I-N commented 4 weeks ago

📚 AppMetrica SDK Version

6.5.0

📝 Description

After migration from 5.2.0 to 6.5.0 appmetrica SDK I got bunch of background crashes because of AppMetricaService binding error

100% of crashes are coming from Android 7.0 and 7.1.2, no other OS version is affected image

I've found this issue on archived repo of appmetrica - https://github.com/yandexmobile/metrica-sdk-android/issues/92 This is exactly my problem, just on a newer SDK version

🔍 Reproducing the issue

  1. Just open the app. According to Firebase this is an early crash, occuring just after 1 second of app running

📋 Relevant AppMetrica Log Output or Crash Logs

Expand to view logs
``` Fatal Exception: java.lang.RuntimeException: Unable to bind to service io.appmetrica.analytics.internal.AppMetricaService@8ca6b22 with Intent { act=io.appmetrica.analytics.IAppMetricaService dat=appmetrica://com.example.app/client?pid=3737&psid=bd4bac8e-7067-4bf7-9932-d36769d8eedd flg=0x20 pkg=com.example.app cmp=com.example.app/io.appmetrica.analytics.internal.AppMetricaService (has extras) }: java.lang.IllegalArgumentException at android.app.ActivityThread.handleBindService(ActivityThread.java:3233) at android.app.ActivityThread.-wrap3(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1573) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6121) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:892) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782) ``` ``` Caused by java.lang.IllegalArgumentException: at android.os.Parcel.nativeAppendFrom(Parcel.java) at android.os.Parcel.appendFrom(Parcel.java:463) at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1395) at android.os.Bundle.writeToParcel(Bundle.java:1157) at android.os.Parcel.writeBundle(Parcel.java:764) at android.content.Intent.writeToParcel(Intent.java:8687) at android.app.ActivityManagerProxy.publishService(ActivityManagerNative.java:4430) at android.app.ActivityThread.handleBindService(ActivityThread.java:3220) at android.app.ActivityThread.-wrap3(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1573) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6121) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:892) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782) ```

📦 Dependencies

alexklints commented 3 weeks ago

Hi. Thank you for your feedback.

The problem arises due to the specifics of the application update process on Android 7. When updating the application, the system does not stop all application processes. This leads to the desynchronization of the client and service code. At the same time, there was a race condition in the implementation of the BaseBundle of this version of AOSP. Unfortunately, we can't do anything about this situation. The good news is that after updating the audience to the current version of the application, the problem should go away (or become much less frequent). If this does not happen, please reopen the issue.