flutter-quill icon indicating copy to clipboard operation
flutter-quill copied to clipboard

Strange behavior when compiling on Android

Open zapiy opened this issue 1 year ago • 21 comments

Is there an existing issue for this?

Flutter Quill version

9.1.1

Steps to reproduce

flutter create test_quill flutter pub add flutter_quill flutter_quill_extensions flutter run

Actual results

First it compiles. It produces a bunch of errors and starts on the phone, but in the end it just hangs on a black screen and hot reload doesn’t help. If you remove these two packages then this error will not occur. It doesn't work in either a real or test project.

Console output

image image

Flutter version

image

Same problem

https://github.com/dart-lang/build/issues/3622 https://github.com/flutter/flutter/issues/139925

Code sample

[Code] main.dart
// [main.dart]
import 'package:flutter/material.dart';
import 'package:flutter_quill/extensions.dart';
import 'package:flutter_quill/flutter_quill.dart';
import 'package:flutter_quill_extensions/embeds/widgets/image.dart';
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late final QuillController _controller;
  final _focusNode = FocusNode();
  final _scrollController = ScrollController();

  @override
  void initState() {
    super.initState();

    const content = [
      {
        "insert": "Hello World!\n",
      }
    ];

    _controller = QuillController(
      document: Document.fromJson(content),
      selection: const TextSelection.collapsed(offset: 0),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
          child: QuillEditor(
              configurations: QuillEditorConfigurations(
                  controller: _controller,
                  scrollable: false,
                  readOnly: false,
                  embedBuilders: (isWeb()
                      ? FlutterQuillEmbeds.editorWebBuilders()
                      : FlutterQuillEmbeds.editorBuilders(
                          imageEmbedConfigurations:
                              QuillEditorImageEmbedConfigurations(
                            imageErrorWidgetBuilder:
                                (context, error, stackTrace) {
                              return Text(
                                'Error while loading an image: ${error.toString()}',
                              );
                            },
                            imageProviderBuilder: (context, url) {
                              if (isAndroid(supportWeb: false) ||
                                  isIOS(supportWeb: false) ||
                                  isWeb()) {
                                if (isHttpBasedUrl(url)) {
                                  return NetworkImage(url);
                                }
                              }
                              return getImageProviderByImageSource(
                                url,
                                imageProviderBuilder: null,
                                context: context,
                                assetsPrefix:
                                    QuillSharedExtensionsConfigurations.get(
                                            context: context)
                                        .assetsPrefix,
                              );
                            },
                          ),
                        ))),
              focusNode: _focusNode,
              scrollController: _scrollController)),
    );
  }
}

Logs

Full text console output
Launching lib\main.dart on M2103K19PG in debug mode...
���⥬� �� 㤠���� ���� 㪠����� ����.
���⥬� �� 㤠���� ���� 㪠����� ����.
�� 㤠���� ���� 㪠����� 䠩�.
�� 㤠���� ���� 㪠����� 䠩�.
Cannot operate on packages inside the cache.
Compiling bin/build_tool_runner.dart to kernel file bin/build_tool_runner.dill.
Error: Couldn't resolve the package 'build_tool' in 'package:build_tool/build_tool.dart'.
bin/build_tool_runner.dart:1:8: Error: Not found: 'package:build_tool/build_tool.dart'
import 'package:build_tool/build_tool.dart' as build_tool;
       ^
bin/build_tool_runner.dart:3:15: Error: Method not found: 'runMain'.
   build_tool.runMain(args);
              ^^^^^^^
Could not find a command named "bin\build_tool_runner.dill".

Usage: dart <command|dart-file> [arguments]

Global options:
-v, --verbose               Show additional command output.
    --version               Print the Dart SDK version.
    --enable-analytics      Enable analytics.
    --disable-analytics     Disable analytics.
    --suppress-analytics    Disallow analytics for this `dart *` run without changing the analytics configuration.
-h, --help                  Print this usage information.

Available commands:
  analyze    Analyze Dart code in a directory.
  compile    Compile Dart to various formats.
  create     Create a new Dart project.
  devtools   Open DevTools (optionally connecting to an existing application).
  doc        Generate API documentation for Dart projects.
  fix        Apply automated fixes to Dart source code.
  format     Idiomatically format Dart source code.
  info       Show diagnostic information about the installed tooling.
  pub        Work with packages.
  run        Run a Dart program.
  test       Run tests for a project.

Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.
���⥬� �� 㤠���� ���� 㪠����� ����.
���⥬� �� 㤠���� ���� 㪠����� ����.
�� 㤠���� ���� 㪠����� 䠩�.
�� 㤠���� ���� 㪠����� 䠩�.
Cannot operate on packages inside the cache.
Compiling bin/build_tool_runner.dart to kernel file bin/build_tool_runner.dill.
Error: Couldn't resolve the package 'build_tool' in 'package:build_tool/build_tool.dart'.
bin/build_tool_runner.dart:1:8: Error: Not found: 'package:build_tool/build_tool.dart'
import 'package:build_tool/build_tool.dart' as build_tool;
       ^
bin/build_tool_runner.dart:3:15: Error: Method not found: 'runMain'.
   build_tool.runMain(args);
              ^^^^^^^
Could not find a command named "bin\build_tool_runner.dill".

Usage: dart <command|dart-file> [arguments]

Global options:
-v, --verbose               Show additional command output.
    --version               Print the Dart SDK version.
    --enable-analytics      Enable analytics.
    --disable-analytics     Disable analytics.
    --suppress-analytics    Disallow analytics for this `dart *` run without changing the analytics configuration.
-h, --help                  Print this usage information.

Available commands:
  analyze    Analyze Dart code in a directory.
  compile    Compile Dart to various formats.
  create     Create a new Dart project.
  devtools   Open DevTools (optionally connecting to an existing application).
  doc        Generate API documentation for Dart projects.
  fix        Apply automated fixes to Dart source code.
  format     Idiomatically format Dart source code.
  info       Show diagnostic information about the installed tooling.
  pub        Work with packages.
  run        Run a Dart program.
  test       Run tests for a project.

Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.
Running Gradle task 'assembleDebug'...                             20,2s
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Syncing files to device M2103K19PG...                              234ms

zapiy avatar Dec 30 '23 00:12 zapiy

The issue is not happening in the example, can you check your Android environment?

EchoEllet avatar Dec 30 '23 12:12 EchoEllet

What exactly should I check there?

zapiy avatar Dec 30 '23 18:12 zapiy

it is caused by super_clipboard, used in flutter_quill as dependancy because it used super_native_extensions which used irondash_engine_context, irondash_message_chann.

Solutions: Currently flutter clean and rebuild again.

salba360496 avatar Jan 01 '24 04:01 salba360496

Facing this same issue. Any solve yet?

SM-SHIFAT avatar Jan 01 '24 15:01 SM-SHIFAT

Solutions: Currently flutter clean and rebuild again.

This didn't help either. I’ve already done this 5 times in a row and install different old versions

zapiy avatar Jan 01 '24 17:01 zapiy

use dart pub cache repair commands to fix pub cache problems. Furthermore, If you try to downgrade to older versions make sure to remove the caret sign (^) from the start of the version numbers otherwise it will install the newest version. Then flutter clean and build again. Hope it will solve your problem.

salba360496 avatar Jan 01 '24 19:01 salba360496

+1, Neither flutter pub cache clean nor flutter clean can solve the problem

hcanyz avatar Jan 02 '24 01:01 hcanyz

Still facing this in ^9.#.# versions, so I downgraded to last ^8.#.#.

SM-SHIFAT avatar Jan 02 '24 03:01 SM-SHIFAT

make sure to remove the caret sign (^) from the start of the version numbers otherwise, it will install the newest version. i.e instead of ^8.#.# use only 8.#.#.

salba360496 avatar Jan 02 '24 03:01 salba360496

Same issue even on lastest 9.2.2, downgraded to 8.6.4

maksim555659 avatar Jan 02 '24 22:01 maksim555659

Can you create the issue on the super_clipboard plugin repository? It probably a issue from the plugin itself

EchoEllet avatar Jan 03 '24 14:01 EchoEllet

Can you create the issue on the super_clipboard plugin repository? It probably a issue from the plugin itself

I think is not caused by other plugin. I run the example Repository (GitHub) and report:

Error: Couldn't resolve the package 'build_tool' in 'package:build_tool/build_tool.dart'. bin/build_tool_runner.dart:1:8: Error: Not found: 'package:build_tool/build_tool.dart' import 'package:build_tool/build_tool.dart' as build_tool; ^ bin/build_tool_runner.dart:3:15: Error: Method not found: 'runMain'. build_tool.runMain(args); ^^^^^^^ Could not find a command named "bin\build_tool_runner.dill".

2426232528 avatar Jan 05 '24 12:01 2426232528

Can you create the issue on the super_clipboard plugin repository? It probably a issue from the plugin itself

I think is not caused by other plugin. I run the example Repository (GitHub) and report:

Error: Couldn't resolve the package 'build_tool' in 'package:build_tool/build_tool.dart'. bin/build_tool_runner.dart:1:8: Error: Not found: 'package:build_tool/build_tool.dart' import 'package:build_tool/build_tool.dart' as build_tool; ^ bin/build_tool_runner.dart:3:15: Error: Method not found: 'runMain'. build_tool.runMain(args); ^^^^^^^ Could not find a command named "bin\build_tool_runner.dill".

The example itself uses the plugin

EchoEllet avatar Jan 05 '24 13:01 EchoEllet

temporary solution: Add ndkVersion in the build.gradle

Снимок экрана 2024-01-08 в 14 11 09

https://developer.android.com/ndk

But this is the wrong way! These kinds of dependencies must be specified inside the library. Please fix

EgorK0rshun avatar Jan 08 '24 11:01 EgorK0rshun

Same issue on android but its work fine on ios and web

in my case, i just downgraded to 8.x.x

rahmanrezaee avatar Jan 09 '24 11:01 rahmanrezaee

Same problem here . Forced to downgrade to 8.6.4

devx-ubiquity avatar Jan 09 '24 13:01 devx-ubiquity

We have two solutions, either we contact with the author of https://pub.dev/packages/super_clipboard

for a solution

Or we replace it with another clipboard plugin

that can:

  1. retrieve html content from the clipboard
  2. Up to date with flutter 3.16 and future versions
  3. Can get an image from clipboard or copy image to the clipboard using base 64

Also make sure to follow the instructions on the plugin README

EchoEllet avatar Jan 09 '24 15:01 EchoEllet

Also make sure to follow the instructions on the plugin README

Maybe you can add the necessary line from the readmi inside the library? It seems to me that it is wrong that every user who uses flutter_quill should register an ndk for themselves.

Smth like this .

I also had this problem after increasing version, reason: Снимок экрана 2024-01-08 в 13 10 53 Снимок экрана 2024-01-09 в 21 32 44

and after an explicit indication version of local ndk in the build.gragle it worked.

EgorK0rshun avatar Jan 09 '24 18:01 EgorK0rshun

Also make sure to follow the instructions on the plugin README

Maybe you can add the necessary line from the readmi inside the library? It seems to me that it is wrong that every user who uses flutter_quill should register an ndk for themselves.

Smth like this .

I also had this problem after increasing version, reason: Снимок экрана 2024-01-08 в 13 10 53 Снимок экрана 2024-01-09 в 21 32 44

and after an explicit indication version of local ndk in the build.gragle it worked.

This is a package, not a plugin. Besides, we can't change the minimum version because it will require the user to change it anyway

Please make sure to follow the instructions and install rust on Windows

I need to know which platform you are using

EchoEllet avatar Jan 09 '24 18:01 EchoEllet

Can you try with 9.2.5? It doesn't contain any fix for the issue, but the new version of the super clipboard has more error messages, and we need it to debug the bug

EchoEllet avatar Jan 15 '24 12:01 EchoEllet

Also make sure to follow the instructions on the plugin README

Maybe you can add the necessary line from the readmi inside the library? It seems to me that it is wrong that every user who uses flutter_quill should register an ndk for themselves.

Smth like this .

I also had this problem after increasing version, reason: Снимок экрана 2024-01-08 в 13 10 53 Снимок экрана 2024-01-09 в 21 32 44

and after an explicit indication version of local ndk in the build.gragle it worked.

May I ask when you created your flutter project? Because all new flutter projects has ndk version by default

EchoEllet avatar Jan 15 '24 12:01 EchoEllet

You can try out with 9.2.6

EchoEllet avatar Jan 16 '24 16:01 EchoEllet

Is there an existing issue for this?

Flutter Quill version

9.1.1

Steps to reproduce

flutter create test_quill flutter pub add flutter_quill flutter_quill_extensions flutter run

Actual results

First it compiles. It produces a bunch of errors and starts on the phone, but in the end it just hangs on a black screen and hot reload doesn’t help. If you remove these two packages then this error will not occur. It doesn't work in either a real or test project.

Console output

image image

Flutter version

image

Same problem

https://github.com/dart-lang/build/issues/3622 https://github.com/flutter/flutter/issues/139925

Code sample

[Code] main.dart
// [main.dart]
import 'package:flutter/material.dart';
import 'package:flutter_quill/extensions.dart';
import 'package:flutter_quill/flutter_quill.dart';
import 'package:flutter_quill_extensions/embeds/widgets/image.dart';
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late final QuillController _controller;
  final _focusNode = FocusNode();
  final _scrollController = ScrollController();

  @override
  void initState() {
    super.initState();

    const content = [
      {
        "insert": "Hello World!\n",
      }
    ];

    _controller = QuillController(
      document: Document.fromJson(content),
      selection: const TextSelection.collapsed(offset: 0),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
          child: QuillEditor(
              configurations: QuillEditorConfigurations(
                  controller: _controller,
                  scrollable: false,
                  readOnly: false,
                  embedBuilders: (isWeb()
                      ? FlutterQuillEmbeds.editorWebBuilders()
                      : FlutterQuillEmbeds.editorBuilders(
                          imageEmbedConfigurations:
                              QuillEditorImageEmbedConfigurations(
                            imageErrorWidgetBuilder:
                                (context, error, stackTrace) {
                              return Text(
                                'Error while loading an image: ${error.toString()}',
                              );
                            },
                            imageProviderBuilder: (context, url) {
                              if (isAndroid(supportWeb: false) ||
                                  isIOS(supportWeb: false) ||
                                  isWeb()) {
                                if (isHttpBasedUrl(url)) {
                                  return NetworkImage(url);
                                }
                              }
                              return getImageProviderByImageSource(
                                url,
                                imageProviderBuilder: null,
                                context: context,
                                assetsPrefix:
                                    QuillSharedExtensionsConfigurations.get(
                                            context: context)
                                        .assetsPrefix,
                              );
                            },
                          ),
                        ))),
              focusNode: _focusNode,
              scrollController: _scrollController)),
    );
  }
}

Logs

Full text console output
Launching lib\main.dart on M2103K19PG in debug mode...
���⥬� �� 㤠���� ���� 㪠����� ����.
���⥬� �� 㤠���� ���� 㪠����� ����.
�� 㤠���� ���� 㪠����� 䠩�.
�� 㤠���� ���� 㪠����� 䠩�.
Cannot operate on packages inside the cache.
Compiling bin/build_tool_runner.dart to kernel file bin/build_tool_runner.dill.
Error: Couldn't resolve the package 'build_tool' in 'package:build_tool/build_tool.dart'.
bin/build_tool_runner.dart:1:8: Error: Not found: 'package:build_tool/build_tool.dart'
import 'package:build_tool/build_tool.dart' as build_tool;
       ^
bin/build_tool_runner.dart:3:15: Error: Method not found: 'runMain'.
   build_tool.runMain(args);
              ^^^^^^^
Could not find a command named "bin\build_tool_runner.dill".

Usage: dart <command|dart-file> [arguments]

Global options:
-v, --verbose               Show additional command output.
    --version               Print the Dart SDK version.
    --enable-analytics      Enable analytics.
    --disable-analytics     Disable analytics.
    --suppress-analytics    Disallow analytics for this `dart *` run without changing the analytics configuration.
-h, --help                  Print this usage information.

Available commands:
  analyze    Analyze Dart code in a directory.
  compile    Compile Dart to various formats.
  create     Create a new Dart project.
  devtools   Open DevTools (optionally connecting to an existing application).
  doc        Generate API documentation for Dart projects.
  fix        Apply automated fixes to Dart source code.
  format     Idiomatically format Dart source code.
  info       Show diagnostic information about the installed tooling.
  pub        Work with packages.
  run        Run a Dart program.
  test       Run tests for a project.

Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.
���⥬� �� 㤠���� ���� 㪠����� ����.
���⥬� �� 㤠���� ���� 㪠����� ����.
�� 㤠���� ���� 㪠����� 䠩�.
�� 㤠���� ���� 㪠����� 䠩�.
Cannot operate on packages inside the cache.
Compiling bin/build_tool_runner.dart to kernel file bin/build_tool_runner.dill.
Error: Couldn't resolve the package 'build_tool' in 'package:build_tool/build_tool.dart'.
bin/build_tool_runner.dart:1:8: Error: Not found: 'package:build_tool/build_tool.dart'
import 'package:build_tool/build_tool.dart' as build_tool;
       ^
bin/build_tool_runner.dart:3:15: Error: Method not found: 'runMain'.
   build_tool.runMain(args);
              ^^^^^^^
Could not find a command named "bin\build_tool_runner.dill".

Usage: dart <command|dart-file> [arguments]

Global options:
-v, --verbose               Show additional command output.
    --version               Print the Dart SDK version.
    --enable-analytics      Enable analytics.
    --disable-analytics     Disable analytics.
    --suppress-analytics    Disallow analytics for this `dart *` run without changing the analytics configuration.
-h, --help                  Print this usage information.

Available commands:
  analyze    Analyze Dart code in a directory.
  compile    Compile Dart to various formats.
  create     Create a new Dart project.
  devtools   Open DevTools (optionally connecting to an existing application).
  doc        Generate API documentation for Dart projects.
  fix        Apply automated fixes to Dart source code.
  format     Idiomatically format Dart source code.
  info       Show diagnostic information about the installed tooling.
  pub        Work with packages.
  run        Run a Dart program.
  test       Run tests for a project.

Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.
Running Gradle task 'assembleDebug'...                             20,2s
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Syncing files to device M2103K19PG...                              234ms

The issue should be fixed in 9.2.6

Please try it out and tell me if it is not fixed

EchoEllet avatar Jan 16 '24 17:01 EchoEllet

After using 9.2.6, irondash_engine_context can be built normally, but super_native_extensions will still fail to build, with the following error 无标题2 The log of running flutter build apk -v is as follows log.txt

mox1206 avatar Jan 17 '24 10:01 mox1206

Can you try installing https://visualstudio.microsoft.com/visual-cpp-build-tools/ ?

It seems that you have Rustup installed, which requires the build tools to work properly on Windows. Another alternative would be to uninstall Rustup, in which case the plugin will just use prebuilt binaries.

knopp avatar Jan 17 '24 10:01 knopp

Can you try installing https://visualstudio.microsoft.com/visual-cpp-build-tools/ ?

It seems that you have Rustup installed, which requires the build tools to work properly on windows Another alternative would be to uninstall Rustup, in which case the plugin will just use prebuilt binaries.

Make sense.

EchoEllet avatar Jan 17 '24 10:01 EchoEllet

Can you try installing https://visualstudio.microsoft.com/visual-cpp-build-tools/ ?

It seems that you have Rustup installed, which requires the build tools to work properly on windows Another alternative would be to uninstall Rustup, in which case the plugin will just use prebuilt binaries.

Thank you very much, I can build normally after uninstalling rust.

mox1206 avatar Jan 18 '24 03:01 mox1206

I'm closing this issue as fixed as @knopp fixed it to all the users of super_clipboard and flutter_quill

If anyone still facing it please let me know

EchoEllet avatar Jan 21 '24 16:01 EchoEllet

To fix the error with "irondash_engine_context", I had to add the missing ndkVersion flutter.ndkVersion line after compileSdkVersion flutter.compileSdkVersion in android/app/build.gradle

MickaelHrndz avatar Feb 29 '24 11:02 MickaelHrndz

To fix the error with "irondash_engine_context", I had to add the missing ndkVersion flutter.ndkVersion line after compileSdkVersion flutter.compileSdkVersion in android/app/build.gradle

That should already be there for any new Flutter generated projects.

knopp avatar Feb 29 '24 12:02 knopp