Skip to content

[native_dio_adapter] All network requests fail when Google Play services are unavailable #2444

Closed

Description

@LukasMirbt

Package

native_dio_adapter

Version

1.5.0

Operating-System

Android

Adapter

NativeAdapter

Steps to Reproduce

  1. Create an Android emulator that does not have access to Google Play Services (select Services -> Android Open Source)
  2. Make a network request on a Dio instance with a NativeAdapter
  3. Note that the request fails and an exception is thrown when initializing the CronetEngine.

Expected Result

NativeAdapter should gracefully handle devices without Google Play services (for example by falling back on IOClient).

Cronet can be embedded as a workaround but in my opinion it's quite a big footgun that all network requests fail on certain devices if the developer is not aware of how cronet_http interacts with Google Play services.

I created a draft PR with a possible approach for handling the issue.

Actual Result

NativeAdapter throws an exception and network requests fail.

JniException (Exception in Java code called through JNI: java.lang.RuntimeException: All available Cronet providers are disabled. A provider should be enabled before it can be used.
      
      java.lang.RuntimeException: All available Cronet providers are disabled. A provider should be enabled before it can be used.
      	at org.chromium.net.CronetEngine$Builder.getEnabledCronetProviders(CronetEngine.java:365)
      	at org.chromium.net.CronetEngine$Builder.createBuilderDelegate(CronetEngine.java:327)
      	at org.chromium.net.CronetEngine$Builder.<init>(CronetEngine.java:75)
      	at android.os.MessageQueue.nativePollOnce(Native Method)
      	at android.os.MessageQueue.next(MessageQueue.java:346)
      	at android.os.Looper.loopOnce(Looper.java:189)
      	at android.os.Looper.loop(Looper.java:317)
      	at android.app.ActivityThread.main(ActivityThread.java:8705)
      	at java.lang.reflect.Method.invoke(Native Method)
      	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
      	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
      )

Activity

  1. added
    h: need triage
    s: bug
    on Sep 17, 2025
  2. changed the title [-][native_dio_adapter] All network requests fail when Google Play Services are unavailable[/-] [+][native_dio_adapter] All network requests fail when Google Play services are unavailable[/+] on Sep 17, 2025
  3. kuhnroyal commented on Sep 17, 2025

    @kuhnroyal
    Member

    Please check https://pub.dev/packages/cronet_http#use-embedded-cronet and cronets general documentation.

  4. LukasMirbt commented on Sep 17, 2025

    @LukasMirbt
    Author

    Please check https://pub.dev/packages/cronet_http#use-embedded-cronet and cronets general documentation.

    Hi! Yes, as mentioned:

    Cronet can be embedded as a workaround but in my opinion it's quite a big footgun that all network requests fail on certain devices if the developer is not aware of how cronet_http interacts with Google Play services.

    In my opinion, it would be a better experience for developers if native_dio_adapter gracefully falls back to IOClient instead of breaking users on certain devices. Let me know if you disagree!

  5. AlexV525 commented on Sep 18, 2025

    @AlexV525
    Member

    I think providing the fallback would be helpful, but maybe opt-in rather by default. Developers should have a chance to realize what they are doing is rely on a thrid-party service.

  6. LukasMirbt commented on Sep 18, 2025

    @LukasMirbt
    Author

    I think providing the fallback would be helpful, but maybe opt-in rather by default. Developers should have a chance to realize what they are doing is rely on a thrid-party service.

    One important aspect of the fallback is to prevent breaking the app for developers that don't realize that this issue exists. By making it opt-in, only developers aware of the issue would benefit from the fallback.

    I do think the fallback behavior also is useful for developers that want to support devices without Google Play services but do not want to add the extra ~5mb app size from embedding Cronet.

    But in my opinion, the number one priority should be to never break any apps.

  7. AlexV525 commented on Sep 21, 2025

    @AlexV525
    Member

    I do think the fallback behavior also is useful for developers that want to support devices without Google Play services but do not want to add the extra ~5mb app size from embedding Cronet.

    There are many useful things, but their gain could be minor. Adding such abilities as a default would bring mental baggage that developers would have more time to obtain precise info from a request, such as determine whether it's coming from native or Dart, or if it's caused by unavailable Play Service or underlying initialization error.

    The initiative of the package was to provide only a bridge to native implementation, and that is how cronet_http and cupertino_http are designed to fit http. Please consider adding more tips/warnings or even a clear exception class to http that can be helpful to indicate No Cronet Service available through Google Play Service. I don't think we should cover so many cases.

    EDIT: Sorry, I accidentally hit the close button.

  8. added a commit that references this issue on Jan 8, 2026
    ceb0586
  9. added a commit that references this issue on Aug 5, 2026
    26ed7e5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    h: need triages: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions