【问题标题】:how to solve: Execution failed for task ':app:compileFlutterBuildDebug'如何解决:任务':app:compileFlutterBuildDebug'执行失败
【发布时间】:2021-12-08 03:43:54
【问题描述】:

运行flutter后出现此错误,我已经切换到master频道并降级了flutter,也切换到了stable频道并降级了。我还删除了 pubspec.lock 然后运行 ​​pub get 仍然出现此错误。

这是整个错误信息:

Launching lib/main.dart on Android SDK built for x86 in debug mode...
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
../../../sdks/flutter/.pub-cache/hosted/pub.dartlang.org/states_rebuilder-1.3.2/lib/src/bloc_provider.dart:22:17: Error: The method 'ancestorInheritedElementForWidgetOfExactType' isn't defined for the class 'BuildContext'.
 - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../sdks/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ancestorInheritedElementForWidgetOfExactType'.
        context.ancestorInheritedElementForWidgetOfExactType(type)?.widget;
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


FAILURE: Build failed with an exception.

* Where:
Script '/home/enel/sdks/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1035

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/home/enel/sdks/flutter/bin/flutter'' 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 8s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

【问题讨论】:

    标签: flutter dart gradle visual-studio-code flutter-dependencies


    【解决方案1】:

    尝试以下方法:

    转到pubspec.yaml 文件,尝试执行Packages get | Pub get,然后再次构建项目。

    或者试试这个:

    flutter clean and flutter pub get
    

    在终端,问题解决了!

    希望能解决!

    【讨论】:

    • 我已经完成了,我仍然得到同样的错误
    猜你喜欢
    • 2020-09-07
    • 2021-05-04
    • 1970-01-01
    • 1970-01-01
    • 2022-07-04
    • 2021-09-25
    • 2021-08-21
    • 1970-01-01
    • 2022-07-04
    相关资源
    最近更新 更多