Skip to content

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

@LukasMirbt

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)
      )

Metadata

Metadata

Assignees

No one assigned

    Labels

    h: need triageThis issue needs to be categorizeds: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions