Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AndroidNetworkListener and AndroidNetworkConnectivityChecker are crashing on Android 11 #197

Closed
milkaman opened this issue May 27, 2024 · 0 comments · Fixed by #221
Closed

Comments

@milkaman
Copy link

Expected Behavior

SDK shouldn't crash because of ConnectivityManager on Android 11

Current Behavior

Now we have few crashes on Android 11 devices:

  1. First one is connected with the call of AndroidNetworkListener.setupNetworkCallback
Fatal Exception: java.lang.SecurityException: Package android does not belong to 10438
      at android.os.Parcel.createExceptionOrNull(Parcel.java:2376)
      at android.os.Parcel.createException(Parcel.java:2360)
      at android.os.Parcel.readException(Parcel.java:2343)
      at android.os.Parcel.readException(Parcel.java:2285)
      at android.net.IConnectivityManager$Stub$Proxy.listenForNetwork(IConnectivityManager.java:3609)
      at android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:3710)
      at android.net.ConnectivityManager.registerNetworkCallback(ConnectivityManager.java:4104)
      at android.net.ConnectivityManager.registerNetworkCallback(ConnectivityManager.java:4074)
      at com.amplitude.android.utilities.AndroidNetworkListener.setupNetworkCallback(AndroidNetworkListener.java:59)
      at com.amplitude.android.utilities.AndroidNetworkListener.startListening(AndroidNetworkListener.java:32)
      at com.amplitude.android.plugins.AndroidNetworkConnectivityCheckerPlugin.setup(AndroidNetworkConnectivityCheckerPlugin.kt:42)
      at com.amplitude.core.platform.Timeline.add(Timeline.kt:23)
      at com.amplitude.core.Amplitude.add(Amplitude.kt:465)
      at com.amplitude.android.Amplitude.buildInternal$suspendImpl(Amplitude.kt:61)
      at com.amplitude.android.Amplitude.buildInternal(Amplitude.kt:1)
      at com.amplitude.core.Amplitude$build$built$1.invokeSuspend(Amplitude.kt:114)
      at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
      at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
      at java.lang.Thread.run(Thread.java:923)
   
  1. Second one relates to the call of AndroidNetworkConnectivityChecker.isConnected
Fatal Exception: java.lang.SecurityException: Package android does not belong to 10511
      at android.os.Parcel.createExceptionOrNull(Parcel.java:2374)
      at android.os.Parcel.createException(Parcel.java:2358)
      at android.os.Parcel.readException(Parcel.java:2341)
      at android.os.Parcel.readException(Parcel.java:2283)
      at android.net.IConnectivityManager$Stub$Proxy.getNetworkCapabilities(IConnectivityManager.java:2456)
      at android.net.ConnectivityManager.getNetworkCapabilities(ConnectivityManager.java:1386)
      at com.amplitude.android.utilities.AndroidNetworkConnectivityChecker.isConnected(AndroidNetworkConnectivityChecker.java:42)
      at com.amplitude.android.plugins.AndroidNetworkConnectivityCheckerPlugin$setup$1.invokeSuspend(AndroidNetworkConnectivityCheckerPlugin.kt:25)
      at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
      at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
      at java.lang.Thread.run(Thread.java:923)
   

Possible Solution

Actually it's a known issue on Android 11: https://issuetracker.google.com/issues/175055271
So the only possible workaround is just adding try-catch block with possible checking build version

Steps to Reproduce

  1. Our cases are 100% background - so maybe it can help for reproducing

Environment

  • Device: Redmi Note 9, Realme C21-Y for example from our crashlytics
  • Device OS and Version: only Android 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant