Skip to content

[Android] ConnectivityManager$TooManyRequestsException caused by multiple registerDefaultNetworkCallback calls #3756

@vijaymsc

Description

@vijaymsc

Platform

Android 12+

Plugin

connectivity_plus

Version

7.0.0

Flutter SDK

3.35

Steps to reproduce

We are unable to reproduce the issue on our end. This issue was reported past 90days approximately 1,000 users are affected according to the Firebase crash report.

Code Sample

Logs

Fatal Exception: android.net.ConnectivityManager$TooManyRequestsException:
       at android.net.ConnectivityManager.convertServiceException(ConnectivityManager.java:4503)
       at android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:4788)
       at android.net.ConnectivityManager.registerDefaultNetworkCallbackForUid(ConnectivityManager.java:5469)
       at android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:5436)
       at android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:5410)
       at androidx.work.impl.utils.NetworkApi24.registerDefaultNetworkCallbackCompat(NetworkApi24.kt:26)
       at androidx.work.impl.constraints.trackers.NetworkStateTracker24.startTracking(NetworkStateTracker.kt:165)
       at androidx.work.impl.constraints.trackers.ConstraintTracker.addListener(ConstraintTracker.kt:52)
       at androidx.work.impl.constraints.controllers.BaseConstraintController$track$1.invokeSuspend(ContraintControllers.kt:62)
       at androidx.work.impl.constraints.controllers.BaseConstraintController$track$1.invoke(ContraintControllers.kt:2)
       at androidx.work.impl.constraints.controllers.BaseConstraintController$track$1.invoke(ContraintControllers.kt:1)
       at kotlinx.coroutines.flow.ChannelFlowBuilder.collectTo$suspendImpl(Builders.kt:316)
       at kotlinx.coroutines.flow.ChannelFlowBuilder.collectTo(Builders.kt:3)
       at kotlinx.coroutines.flow.CallbackFlowBuilder.collectTo(Builders.kt:330)
       at kotlinx.coroutines.flow.internal.ChannelFlow$collectToFun$1.invokeSuspend(ChannelFlow.kt:56)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
       at androidx.work.impl.utils.SerialExecutorImpl$Task.run(SerialExecutorImpl.java:96)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1154)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:652)
       at java.lang.Thread.run(Thread.java:1564)

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.35.1, on macOS 26.2 25C56 darwin-arm64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 26.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.3)
[✓] Connected device (3 available)
    ! Error: Browsing on the local area network for admin’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

Checklist before submitting a bug

  • I searched issues in this repository and couldn't find such bug/problem
  • I Google'd a solution and I couldn't find it
  • I searched on StackOverflow for a solution and I couldn't find it
  • I read the README.md file of the plugin
  • I'm using the latest version of the plugin
  • All dependencies are up to date with flutter pub upgrade
  • I did a flutter clean
  • I tried running the example project

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions