Skip to content

native adapter incompatible with cronet_http 1.9.0 #2581

Closed

Description

@fluttersiast

Package

dio

Version

1.7.0

Operating-System

Android

Adapter

NativeAdapter

Output of flutter doctor -v

JNI in cronet should be bump to 1.0 in other case it's incompatible with latest version

Dart Version

No response

Steps to Reproduce

use latest cronet with native dio adapter

Expected Result

compatible

Actual Result

incompatible

Activity

  1. added
    h: need triage
    s: bug
    on Jul 27, 2026
  2. CaiJingLong commented on Jul 27, 2026

    @CaiJingLong
    Contributor

    Confirmed — version solving fails

    I reproduced the incompatibility. It is a dependency-constraint conflict, not a runtime crash: native_dio_adapter 1.7.0 pins package:jni to ^0.14.0, while cronet_http 1.9.0 requires package:jni ^1.0.0. The two jni constraints are disjoint, so flutter pub get fails before any code runs.

    Root cause

    plugins/native_dio_adapter/pubspec.yaml (1.7.0, also current main):

      cronet_http: ^1.5.0   # allows 1.9.0 to be selected
      jni: ^0.14.0          # = >=0.14.0 <0.15.0

    cronet_http 1.9.0 (changelog) bumped package:jni to 1.0 and package:jnigen to 0.16.0, so its pubspec declares:

      jni: ^1.0.0           # = >=1.0.0 <2.0.0

    ^0.14.0 ∩ ^1.0.0 = ∅, and cronet_http: ^1.5.0 lets pub pick 1.9.0, so resolution dead-ends. The jni constraint in native_dio_adapter was added intentionally (see the comment in pubspec.yaml) to track the version cronet_http: ^1.5.0 resolved to — that assumption broke when cronet_http crossed the jni 0.x → 1.0 boundary.

    A secondary blocker: lib/src/cronet_fallback_adapter.dart imports JniException from package:jni:

    import 'package:jni/jni.dart' show JniException;
    ...
    bool isCronetProviderUnavailable(Object error) =>
        error is JniException &&
        error.message.contains(cronetProvidersDisabledMessage);

    JniException is not part of the jni 1.0 API (it was replaced by JThrowable), so bumping the constraint also requires updating this classification code.

    Minimal reproduction

    pubspec.yaml (Flutter app, nothing else needed — the failure is at pub get):

    name: repro_2581
    environment:
      sdk: ^3.4.0
      flutter: '>=3.22.0'
    dependencies:
      flutter:
        sdk: flutter
      native_dio_adapter: 1.7.0
      cronet_http: 1.9.0

    Run:

    flutter pub get

    Observed output

    Resolving dependencies...
    Because cronet_http >=1.9.0 depends on jni ^1.0.0 and native_dio_adapter >=1.7.0 depends on jni ^0.14.0, cronet_http >=1.9.0 is incompatible with native_dio_adapter >=1.7.0.
    So, because repro_2581 depends on both native_dio_adapter 1.7.0 and cronet_http 1.9.0, version solving failed.
    
    
    You can try the following suggestion to make the pubspec resolve:
    * Consider downgrading your constraint on cronet_http: flutter pub add cronet_http:^1.6.0
    

    Correspondence to the report

    The "incompatible" actual result in the issue is exactly this resolution failure. The report's note "JNI in cronet should be bump to 1.0" matches the fix direction: relax jni to ^1.0.0 (or a range spanning both, e.g. >=0.14.0 <2.0.0) and migrate JniException → JThrowable in cronet_fallback_adapter.dart.

    Environment

    • native_dio_adapter: 1.7.0 (also verified on current main)
    • cronet_http: 1.9.0
    • Flutter: 3.24.3 (stable), Dart 3.5.x

    Workaround for affected users

    Pin cronet_http to ^1.6.0 (i.e. <=1.8.0) until native_dio_adapter ships a release with a widened jni constraint:

    flutter pub add cronet_http:^1.6.0

    Note

    A related request was filed in #2580 ("Add support for jni 1.0.0") but was closed because it used the infra/blank template, which is restricted to moderators. The underlying ask — widen jni and migrate off JniException — is the same as what this issue points at.

    This comment was generated by AI agent omp (model: devin/glm-5-2).

  3. added a commit that references this issue on Jul 29, 2026
    bd779cd
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