Skip to content

[Bug]:[share_plus] Unable to build for web #2812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
8 tasks done
imhafeez opened this issue Apr 3, 2024 · 6 comments
Closed
8 tasks done

[Bug]:[share_plus] Unable to build for web #2812

imhafeez opened this issue Apr 3, 2024 · 6 comments
Labels
bug Something isn't working triage

Comments

@imhafeez
Copy link

imhafeez commented Apr 3, 2024

Platform

web

Plugin

share_plus

Version

8.0.2

Flutter SDK

3.19.0

Steps to reproduce

flutter web build

Code Sample

No response

Logs

Target dart2js failed: ProcessException: Process exited abnormally with exit code 253:
../../../../.pub-cache/hosted/pub.dev/share_plus-8.0.2/lib/src/share_plus_web.dart:307:20:
Internal Error: Unknown external method j:method(ShareData|constructor#text)
  external factory ShareData.text({
                   ^
The compiler is broken.

When compiling the above element, the compiler crashed. It is not
possible to tell if this is caused by a problem in your program or
not. Regardless, the compiler should not crash.

The Dart team would greatly appreciate if you would take a moment to
report this problem at http://dartbug.com/new.

Please include the following information:

* the name and version of your operating system,

* the Dart SDK build number (3.3.0), and

* the entire message you see here (including the full stack trace
  below as well as the source location above).

The compiler crashed: Assertion failure: Unknown external method j:method(ShareData|constructor#text)
#0      failedAt (package:compiler/src/diagnostics/invariant.dart:39:3)
#1      KernelSsaGraphBuilder._buildExternalFunctionNode (package:compiler/src/ssa/builder.dart:1825:5)
#2      KernelSsaGraphBuilder.build.<anonymous closure> (package:compiler/src/ssa/builder.dart:439:15)
#3      DiagnosticReporter.withCurrentElement (package:compiler/src/diagnostics/diagnostic_listener.dart:154:15)
#4      KernelSsaGraphBuilder.build (package:compiler/src/ssa/builder.dart:427:21)
#5      KernelSsaBuilder.build.<anonymous closure> (package:compiler/src/js_model/js_strategy.dart:525:22)
#6      CompilerTask.measure (package:compiler/src/common/tasks.dart:66:51)
#7      KernelSsaBuilder.build (package:compiler/src/js_model/js_strategy.dart:507:18)
#8      SsaBuilderTask.build (package:compiler/src/ssa/ssa.dart:365:21)
#9      SsaFunctionCompiler.compile (package:compiler/src/ssa/ssa.dart:99:28)
#10     OnDemandCodegenResults.getCodegenResults (package:compiler/src/common/codegen.dart:409:30)
#11     JsBackendStrategy.generateCode (package:compiler/src/js_model/js_strategy.dart:331:43)
#12     KernelCodegenWorkItem.run (package:compiler/src/js_model/js_strategy.dart:466:29)
#13     Compiler.emptyQueue.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:compiler/src/compiler.dart:752:70)
#14     CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
#15     Compiler.emptyQueue.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:compiler/src/compiler.dart:752:32)
#16     CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
#17     Compiler.emptyQueue.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:compiler/src/compiler.dart:750:28)
#18     DiagnosticReporter.withCurrentElement (package:compiler/src/diagnostics/diagnostic_listener.dart:154:15)
#19     Compiler.emptyQueue.<anonymous closure>.<anonymous closure> (package:compiler/src/compiler.dart:748:18)
#20     CodegenEnqueuer._forEach (package:compiler/src/js_backend/enqueuer.dart:266:12)
#21     CodegenEnqueuer.forEach (package:compiler/src/js_backend/enqueuer.dart:282:5)
#22     Compiler.emptyQueue.<anonymous closure> (package:compiler/src/compiler.dart:744:16)
#23     CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
#24     Compiler.emptyQueue (package:compiler/src/compiler.dart:743:14)
#25     Compiler.processQueue.<anonymous closure> (package:compiler/src/compiler.dart:767:7)
#26     CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
#27     Compiler.processQueue (package:compiler/src/compiler.dart:761:14)
#28     Compiler.runCodegenEnqueuer (package:compiler/src/compiler.dart:472:5)
#29     Compiler.runSequentialPhases (package:compiler/src/compiler.dart:680:27)
<asynchronous suspension>
#30     Compiler.runInternal.<anonymous closure> (package:compiler/src/compiler.dart:315:7)
<asynchronous suspension>
#31     Compiler.runInternal (package:compiler/src/compiler.dart:314:5)
<asynchronous suspension>
#32     Compiler.run.<anonymous closure> (package:compiler/src/compiler.dart:235:11)
<asynchronous suspension>
#33     compile.<anonymous closure> (package:compiler/compiler_api.dart:256:30)
<asynchronous suspension>
#34     compile.compilationDone (package:compiler/src/dart2js.dart:729:3)
<asynchronous suspension>
#35     main (package:compiler/src/dart2js.dart:1233:3)
<asynchronous suspension>
  Command: /Users/hafeez/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev /Users/hafeez/flutter/bin/cache/dart-sdk/bin/snapshots/dart2js.dart.snapshot --platform-binaries=/Users/hafeez/flutter/bin/cache/flutter_web_sdk/kernel
  --invoker=flutter_tool -Ddart.vm.product=true -DFLUTTER_WEB_AUTO_DETECT=true -DFLUTTER_WEB_CANVASKIT_URL=https://www.gstatic.com/flutter-canvaskit/04817c99c9fd4956f27505204f7e344335810aed/ --native-null-assertions --no-source-maps -O4
  -o /Users/hafeez/Documents/Projects/lek/lek-app/.dart_tool/flutter_build/846120b4c5c0513ff1e25f1352e8304a/main.dart.js /Users/hafeez/Documents/Projects/lek/lek-app/.dart_tool/flutter_build/846120b4c5c0513ff1e25f1352e8304a/app.dill
#0      RunResult.throwException (package:flutter_tools/src/base/process.dart:127:5)
#1      _DefaultProcessUtils.run (package:flutter_tools/src/base/process.dart:326:19)
<asynchronous suspension>
#2      Dart2JSTarget.build (package:flutter_tools/src/build_system/targets/web.dart:192:5)
<asynchronous suspension>
#3      _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:861:9)
<asynchronous suspension>
#4      Future.wait.<anonymous closure> (dart:async/future.dart:518:21)
<asynchronous suspension>
#5      _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:799:32)
<asynchronous suspension>
#6      Future.wait.<anonymous closure> (dart:async/future.dart:518:21)
<asynchronous suspension>
#7      _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:799:32)
<asynchronous suspension>
#8      FlutterBuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:628:16)
<asynchronous suspension>
#9      WebBuilder.buildWeb (package:flutter_tools/src/web/compile.dart:93:34)
<asynchronous suspension>
#10     BuildWebCommand.runCommand (package:flutter_tools/src/commands/build_web.dart:200:5)
<asynchronous suspension>
#11     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1389:27)
<asynchronous suspension>
#12     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#13     CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#14     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:355:9)
<asynchronous suspension>
#15     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#16     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:295:5)
<asynchronous suspension>
#17     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:119:9)
<asynchronous suspension>
#18     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#19     main (package:flutter_tools/executable.dart:90:3)
<asynchronous suspension>

Compiling lib/main.dart for the Web...                             34.2s
Error: Failed to compile application for the Web.

Flutter Doctor

[✓] Flutter (Channel stable, 3.19.0, on macOS 14.4.1 23E224 darwin-arm64, locale en-PK)
    • Flutter version 3.19.0 on channel stable at /Users/hafeez/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision bae5e49bc2 (7 weeks ago), 2024-02-13 17:46:18 -0800
    • Engine revision 04817c99c9
    • Dart version 3.3.0
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/hafeez/Library/Android/sdk
    • Platform android-34, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.87.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.84.0

[✓] Connected device (6 available)
    • Hafeez’s iPhone 12 Pro (mobile)     • 00008101-000E14CA3A8B001E                • ios            • iOS 17.3.1 21D61
    • Hafeez’s iPad (mobile)              • 46618cbc3abfaab6809d3489d98746f2d1f90adb • ios            • iOS 16.5 20F66
    • iPhone 15 Plus (mobile)             • 75D74010-5E0B-442C-9C2C-B34E06C9F7AA     • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • iPad mini (6th generation) (mobile) • EEEC1BF7-CE12-4F9F-9B40-FEE34C2DEBFC     • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)                     • macos                                    • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
    • Chrome (web)                        • chrome                                   • web-javascript • Google Chrome 122.0.6261.112

[✓] Network resources
    • All expected network resources are available.

• No issues found!

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
@imhafeez imhafeez added bug Something isn't working triage labels Apr 3, 2024
@miquelbeltran
Copy link
Member

I cannot reproduce the issue, the project compiles for me.

> flutter build web
Resolving dependencies... 
  ffi 2.1.0 (2.1.2 available)
  flutter_lints 3.0.1 (3.0.2 available)
  image_picker_android 0.8.9+3 (0.8.9+5 available)
  image_picker_for_web 3.0.2 (3.0.3 available)
  image_picker_ios 0.8.9+1 (0.8.9+2 available)
  image_picker_platform_interface 2.9.3 (2.9.4 available)
  leak_tracker 10.0.0 (10.0.5 available)
  leak_tracker_flutter_testing 2.0.1 (3.0.5 available)
  leak_tracker_testing 2.0.1 (3.0.1 available)
  material_color_utilities 0.8.0 (0.11.1 available)
  meta 1.11.0 (1.12.0 available)
! share_plus 8.0.1 from path .. (overridden in ./pubspec_overrides.yaml)
! share_plus_platform_interface 3.3.1 from path ../../share_plus_platform_interface (overridden in ./pubspec_overrides.yaml)
  test_api 0.6.1 (0.7.0 available)
  vm_service 13.0.0 (14.2.0 available)
  win32 5.2.0 (5.4.0 available)
Got dependencies!
14 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.

Upgrading .gitignore
Expected to find fonts for (MaterialIcons, packages/cupertino_icons/CupertinoIcons), but found (MaterialIcons). This usually
means you are referring to font families in an IconData class but not including them in the assets section of your
pubspec.yaml, are missing the package that would include them, or are missing "uses-material-design: true".
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 7848 bytes (99.5% reduction). Tree-shaking
can be disabled by providing the --no-tree-shake-icons flag when building your app.
Compiling lib/main.dart for the Web...                             24.9s
  • Can you provide the exact command you are using to build the project?

I tried running the example project

  • Did you try this? Were you able to compile the example project for web?

@butterbrain
Copy link

I got this problem just as I upgraded my plugins... It doesn't fix the problem, but it moved me onwards to build with share_plus: ^7.2.1 instead if that helps at all. I submitted the error to the compiler team as my error crashes the web compiler and they asked that I submit the report as a crash isn't what they wanted (O:

@butterbrain
Copy link

From the Dart team:

There was an issue with the Dart stable 3.3.0 SDK, which was then fixed in a patch release with Dart 3.3.1. The issue was that object-literal JS-interop constructors (such SharedData.files here) didn't work in dart2js unless the enclosing library had a @js() annotation. Instead of reporting an error, the compiler crashed! I believe it was because this used to be required in the old interop, but we decided it shouldn't be required anymore, but then one part of the compiled wasn't adjusted to properly understand code without the annotation. More details available in the issue describing the 3.3.1 cherry-pick:
#55057

Since this is now released in the stable channel, most likely the only thing you need to do is to update to the latest stable release of Dart and Flutter.

@miquelbeltran
Copy link
Member

Thanks for the help @butterbrain !

I can see that @imhafeez uses Dart version 3.3.0 in their flutter doctor output. In my case, I was already in Dart version 3.3.1. Probably also why the GitHub CI build process didn't catch this either.

Please @imhafeez confirm if that's the case and close the issue.

@imhafeez
Copy link
Author

imhafeez commented Apr 4, 2024

Thanks @butterbrain @miquelbeltran. It compiled successfully after flutter upgrade.

I am closing now.

@veloso14
Copy link

Thanks, 3.3.1 also builds now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

4 participants