【问题标题】:Execution failed for task ':app:compileFlutterBuildRelease'. Flutter任务 ':app:compileFlutterBuildRelease' 执行失败。扑
【发布时间】:2022-01-23 15:11:42
【问题描述】:

我是新来的颤振并面临这个问题。当我在调试模式下运行应用程序时,应用程序运行良好,但是当我运行命令时。

我是新来的颤振并面临这个问题。当我在调试模式下运行应用程序时,应用程序运行良好,但是当我运行命令时。

我是新来的颤振并面临这个问题。当我在调试模式下运行应用程序时,应用程序运行良好,但是当我运行命令时

flutter build apk --release

我收到了这个错误

Warning: You are using these overridden dependencies:
! http 0.12.2 (0.13.4 available)
! intl 0.17.0
Running "flutter pub get" in Food-Delivery---Customer...            5.8s
The plugin `google_maps_flutter` uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future  
release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety

/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_place_picker-0.9.2/lib/src/components/prediction_tile.dart:29:51: Error: The getter 'title' isn't defined 
for the class 'TextTheme'.
 - 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/material/text_theme.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'title'.
    final textColor = Theme.of(context).textTheme.title.color;
                                                  ^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:432:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart').
Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'.
      channel.setMockMessageHandler((dynamic message) async {
              ^^^^^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:440:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart').       
Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'.
      channel.setMockMessageHandler((dynamic message) async {
              ^^^^^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:451:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart').
Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'.
      channel.setMockMessageHandler((dynamic message) async {
              ^^^^^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:463:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart').
Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'.
      channel.setMockMessageHandler((dynamic message) async {
              ^^^^^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:475:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart').       
Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'.
      channel.setMockMessageHandler((dynamic message) async {
              ^^^^^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:487:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart').       
Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'.
      channel.setMockMessageHandler((dynamic message) async {
              ^^^^^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:499:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart').       
Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'.
      channel.setMockMessageHandler((dynamic message) async {
              ^^^^^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:510:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart').       
Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'.
      channel.setMockMessageHandler((dynamic message) async {
              ^^^^^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:521:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart').       
Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'.
      channel.setMockMessageHandler((dynamic message) async {
              ^^^^^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:532:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart').       
Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'.
      channel.setMockMessageHandler((dynamic message) async {
              ^^^^^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:544:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart').       
Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'.
      channel.setMockMessageHandler((dynamic message) async {
              ^^^^^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock_platform_interface-0.1.0+1/lib/messages.dart:96:17: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart').       
Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'.
        channel.setMockMessageHandler(null);
                ^^^^^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock_platform_interface-0.1.0+1/lib/messages.dart:98:17: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart').       
Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'.
        channel.setMockMessageHandler((dynamic message) async {
                ^^^^^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock_platform_interface-0.1.0+1/lib/messages.dart:111:17: Error: The method 'setMockMessageHandler' isn't defined 
for the class 'BasicMessageChannel<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart').       
Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'.
        channel.setMockMessageHandler(null);
                ^^^^^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock_platform_interface-0.1.0+1/lib/messages.dart:113:17: Error: The method 'setMockMessageHandler' isn't defined 
for the class 'BasicMessageChannel<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart').       
Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'.
        channel.setMockMessageHandler((dynamic message) async {
                ^^^^^^^^^^^^^^^^^^^^^


FAILURE: Build failed with an exception.

* Where:
Script 'C:\Flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'C:\Flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 30s
Running Gradle task 'assembleRelease'...                           91.4s
Gradle task assembleRelease failed with exit code 1

【问题讨论】:

  • 您是否尝试过解决控制台中出现的问题?
  • 我的代码没有错误。正如我提到的代码在我调试时工作正常,它只在我尝试发布 apk 时给出错误
  • 尝试在配置文件模式下运行您的应用一次。

标签: flutter dart


【解决方案1】:

问题来自google_maps_flutter插件,您使用的版本已被弃用,并且您当前的SDK版本不允许构建apk,您的代码可能是正确的,但插件的代码肯定有错误,因此出现错误,我建议使用插件的更新版本。

【讨论】:

  • 兄弟你能解释一下你怎么知道这个错误是因为google_maps_flutter?
  • 这里说明了插件google_maps_flutter 使用了已弃用的Android 嵌入版本。为避免意外的运行时失败或未来的构建失败,请尝试查看此插件是否支持 Android V2 嵌入。否则,请考虑将其删除,因为 Flutter 的未来版本将删除这些已弃用的 API。如果您是插件作者,请查看将插件迁移到 V2 嵌入的文档:flutter.dev/go/android-plugin-migration
  • 还有这个 /C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_place_picker-0.9.2/lib/src/components/prediction_tile.dart:29:51 :错误:没有为“TextTheme”类定义吸气剂“标题”。 - “TextTheme”来自“package:flutter/src/material/text_theme.dart”(“/C:/Flutter/flutter/packages/flutter/lib/src/material/text_theme.dart”)。尝试将名称更正为现有 getter 的名称,或定义一个名为“title”的 getter 或字段。最终 textColor = Theme.of(context).textTheme.title.color;第一行告诉你错误文件来自哪里
  • 谢谢兄弟让我试试解决这个问题
  • 您解决了这个问题吗?
【解决方案2】:

您收到overridden dependencies 是因为您可能覆盖了一些您已经在使用的依赖项。例如,如果您为 http 插件使用 path: 0.12.2 并且其他一些依赖项使用 dependency_overrides 以确保使用 path: 0.13.4,它会向您显示该消息。

你会收到一条不赞成的消息,比如

The plugin ```google_maps_flutter``` uses a deprecated version of the Android embedding.

这是因为新的颤振更新。你无能为力。使用其他包或要求包开发人员解决问题。这个错误出现在flutter 2.5版本之后。 要么 或者您可以切换到另一个可以完成相同任务的包。直到包作者更新到 v2 Android 嵌入

【讨论】:

  • 谢谢兄弟。让我试着解决这个问题
猜你喜欢
  • 1970-01-01
  • 2021-07-13
  • 2020-06-13
  • 2020-10-14
  • 1970-01-01
  • 1970-01-01
  • 2021-08-03
  • 2020-06-04
  • 2020-03-07
相关资源
最近更新 更多