Skip to content

[BUG]: Only JS interop members may be 'external'. Try removing the 'external' keyword or adding a JS interop annotation #430

@sb-dor

Description

@sb-dor

When running the Flutter project on the web, the build fails with an error related to the jni package, which is used by cronet_http. Additionally, an unhandled exception occurs during compilation in the cupertino_http package:

Unhandled exception:
Unsupported operation: Unsupported invalid type InvalidType(<invalid>) (InvalidType). Encountered while compiling file:///Users/avaz/.pub-cache/hosted/pub.dev/cupertino_http-2.2.0/lib/src/cupertino_api.dart, which contains the type: FunctionType(void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse, NSURLRequest, ObjCBlock<<invalid> Function(NSURLRequest?)>)).`

`../../../.pub-cache/hosted/pub.dev/jni-0.12.2/lib/src/third_party/jni_bindings_generated.dart:2256:43: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
              ffi.Pointer<JValue> args)>> CallFloatMethodA;
                                          ^
../../../.pub-cache/hosted/pub.dev/jni-0.12.2/lib/src/third_party/jni_bindings_generated.dart:2261:7: Error: Only JS interop members may be 'external'.
Try removing the 'external' keyword or adding a JS interop annotation.
      CallDoubleMethod;
      ^

Unhandled exception:
Unsupported operation: Unsupported invalid type InvalidType(<invalid>) (InvalidType). Encountered while compiling file:///Users/avaz/.pub-cache/hosted/pub.dev/cupertino_http-2.2.0/lib/src/cupertino_api.dart, which contains the type: FunctionType(void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse, NSURLRequest, ObjCBlock<<invalid> Function(NSURLRequest?)>)).
#0      ProgramCompiler._typeCompilationError (package:dev_compiler/src/kernel/compiler.dart:3471)
#1      ProgramCompiler._emitType (package:dev_compiler/src/kernel/compiler.dart:3439)
#2      ProgramCompiler._emitFunctionTagged (package:dev_compiler/src/kernel/compiler.dart:3272)
#3      ProgramCompiler.visitFunctionExpression (package:dev_compiler/src/kernel/compiler.dart:7197)
#4      FunctionExpression.accept (package:kernel/src/ast/expressions.dart:4608)
#5      ProgramCompiler._visitExpression (package:dev_compiler/src/kernel/compiler.dart:4092)
#6      ProgramCompiler._emitArgumentList (package:dev_compiler/src/kernel/compiler.dart:6442)
#7      ProgramCompiler._emitMethodCall (package:dev_compiler/src/kernel/compiler.dart:5421)
#8      ProgramCompiler.visitInstanceInvocation (package:dev_compiler/src/kernel/compiler.dart:5329)
#9      InstanceInvocation.accept (package:kernel/src/ast/expressions.dart:1793)
#10     ProgramCompiler._visitExpression (package:dev_compiler/src/kernel/compiler.dart:4092)
#11     ProgramCompiler.visitExpressionStatement (package:dev_compiler/src/kernel/compiler.dart:4173)
#12     ExpressionStatement.accept (package:kernel/src/ast/statements.dart:50)
#13     ProgramCompiler._visitStatement (package:dev_compiler/src/kernel/compiler.dart:3997)
#14     MappedIterable.elementAt (dart:_internal/iterable.dart:402)
#15     ListIterator.moveNext (dart:_internal/iterable.dart:371)
#16     new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:190)
#17     new _GrowableList.of (dart:core-patch/growable_array.dart:150)
#18     new List.of (dart:core-patch/array_patch.dart:40)
#19     SetBase.toList (dart:collection/set.dart:119)
#20     ProgramCompiler.visitBlock (package:dev_compiler/src/kernel/compiler.dart:4186)
#21     Block.accept (package:kernel/src/ast/statements.dart:103)
#22     ProgramCompiler._visitStatement (package:dev_compiler/src/kernel/compiler.dart:3997)
#23     ProgramCompiler._visitScope (package:dev_compiler/src/kernel/compiler.dart:4786)
#24     ProgramCompiler.visitIfStatement (package:dev_compiler/src/kernel/compiler.dart:4776)
#25     IfStatement.accept (package:kernel/src/ast/statements.dart:1013)
#26     ProgramCompiler._visitStatement (package:dev_compiler/src/kernel/compiler.dart:3997)
#27     MappedIterable.elementAt (dart:_internal/iterable.dart:402)
#28     ListIterator.moveNext (dart:_internal/iterable.dart:371)
#29     new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:190)
#30     new _GrowableList.of (dart:core-patch/growable_array.dart:150)
#31     new List.of (dart:core-patch/array_patch.dart:40)
#32     SetBase.toList (dart:collection/set.dart:119)
#33     ProgramCompiler.visitBlock (package:dev_compiler/src/kernel/compiler.dart:4186)
#34     Block.accept (package:kernel/src/ast/statements.dart:103)
#35     ProgramCompiler._visitStatement (package:dev_compiler/src/kernel/compiler.dart:3997)
#36     ProgramCompiler._emitFunctionScopedBody (package:dev_compiler/src/kernel/compiler.dart:4030)
#37     ProgramCompiler._emitFunction.<anonymous closure> (package:dev_compiler/src/kernel/compiler.dart:3640)
#38     ProgramCompiler._withLetScope (package:dev_compiler/src/kernel/compiler.dart:2779)
#39     ProgramCompiler._withCurrentFunction (package:dev_compiler/src/kernel/compiler.dart:3775)
#40     ProgramCompiler._emitFunction (package:dev_compiler/src/kernel/compiler.dart:3633)
#41     ProgramCompiler._emitMethodDeclaration.<anonymous closure> (package:dev_compiler/src/kernel/compiler.dart:2330)
#42     ProgramCompiler._withMethodDeclarationContext (package:dev_compiler/src/kernel/compiler.dart:3802)
#43     ProgramCompiler._emitMethodDeclaration (package:dev_compiler/src/kernel/compiler.dart:2328)
#44     ProgramCompiler._emitClassMethods (package:dev_compiler/src/kernel/compiler.dart:2269)
#45     ProgramCompiler._emitClassDeclaration (package:dev_compiler/src/kernel/compiler.dart:1070)
#46     ProgramCompiler._emitClass (package:dev_compiler/src/kernel/compiler.dart:1001)
#47     List.forEach (dart:core-patch/growable_array.dart:421)
#48     ProgramCompiler._emitLibrary (package:dev_compiler/src/kernel/compiler.dart:940)
#49     List.forEach (dart:core-patch/growable_array.dart:421)
#50     ProgramCompiler.emitModule (package:dev_compiler/src/kernel/compiler.dart:629)
#51     IncrementalJavaScriptBundler.compile (package:frontend_server/src/javascript_bundle.dart:246)
#52     FrontendCompiler.writeJavaScriptBundle (package:frontend_server/frontend_server.dart:877)
<asynchronous suspension>
#53     FrontendCompiler.compile (package:frontend_server/frontend_server.dart:693)
<asynchronous suspension>
#54     listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1401)
<asynchronous suspension>
the Dart compiler exited unexpectedly.
Failed to compile application.

Environment:

  • Browser [Chrome]
  • Version 137.0.7151.104 (Official build) (arm64)

Additional context

  • flutter --version
Flutter 3.29.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision ea121f8859 (9 weeks ago) • 2025-04-11 19:10:07 +0000
Engine • revision cf56914b32
Tools • Dart 3.7.2 • DevTools 2.42.3
  • flutter doctor
[✓] Flutter (Channel stable, 3.29.3, on macOS 15.3.1 24D70 darwin-arm64, locale ru-RU)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] VS Code (version 1.100.3)
[✓] Connected device (4 available)
[✓] Network resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions