尝试构建时出现此错误-任务':app:compileFlutterBuildDebug'的执行失败

时间:2020-09-21 09:37:57

标签: flutter dart

有人可以帮助我解决此错误吗

任务':app:compileFlutterBuildDebug'的执行失败。

这些是我的pubspec.yaml依赖项(我已将它们全部更新为最新版本):

dependencies:
  flutter:
    sdk: flutter
  in_app_purchase: ^0.3.4+5
  provider: ^4.3.2+2
  intl: ^0.16.0
  http: ^0.12.2
  shared_preferences: ^0.5.7
  font_awesome_flutter: ^8.8.1
  sentry: ">=3.0.0 <4.0.0"

错误的完整堆栈:

Launching lib/main.dart on sdk gphone x86 64 arm64 in debug mode...
Running Gradle task 'assembleDebug'...
Invalid depfile: /home/dimitar/Dropbox/flutter/nufc/.dart_tool/flutter_build/6fca2b889a0849e99a4ed0a0ec9503c5/kernel_snapshot.d
Invalid depfile: /home/dimitar/Dropbox/flutter/nufc/.dart_tool/flutter_build/6fca2b889a0849e99a4ed0a0ec9503c5/kernel_snapshot.d
../../../flutter/.pub-cache/hosted/pub.dartlang.org/sentry-3.0.1/lib/src/browser.dart:7:8: Error: Not found: 'dart:html'
import 'dart:html' hide Event, Client;
       ^
../../../flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.2/lib/src/browser_client.dart:6:8: Error: Not found: 'dart:html'
import 'dart:html';
       ^
../../../flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.2/lib/src/browser_client.dart:34:18: Error: 'HttpRequest' isn't a type.
  final _xhrs = <HttpRequest>{};
                 ^^^^^^^^^^^
../../../flutter/.pub-cache/hosted/pub.dartlang.org/sentry-3.0.1/lib/src/browser.dart:51:19: Error: Getter not found: 'window'.
    origin ??= '${window.location.origin}/';
                  ^^^^^^
../../../flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.2/lib/src/browser_client.dart:58:34: Error: 'Blob' isn't a type.
      var blob = xhr.response as Blob ?? Blob([]);
                                 ^^^^
../../../flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.2/lib/src/browser_client.dart:46:15: Error: The method 'HttpRequest' isn't defined for the class 'BrowserClient'.
 - 'BrowserClient' is from 'package:http/src/browser_client.dart' ('../../../flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.2/lib/src/browser_client.dart').
Try correcting the name to the name of an existing method, or defining a method named 'HttpRequest'.
    var xhr = HttpRequest();
              ^^^^^^^^^^^
../../../flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.2/lib/src/browser_client.dart:58:42: Error: The method 'Blob' isn't defined for the class 'BrowserClient'.
 - 'BrowserClient' is from 'package:http/src/browser_client.dart' ('../../../flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.2/lib/src/browser_client.dart').
Try correcting the name to the name of an existing method, or defining a method named 'Blob'.
      var blob = xhr.response as Blob ?? Blob([]);
                                         ^^^^
../../../flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.2/lib/src/browser_client.dart:59:20: Error: The method 'FileReader' isn't defined for the class 'BrowserClient'.
 - 'BrowserClient' is from 'package:http/src/browser_client.dart' ('../../../flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.2/lib/src/browser_client.dart').
Try correcting the name to the name of an existing method, or defining a method named 'FileReader'.
      var reader = FileReader();
                   ^^^^^^^^^^
Unhandled exception:
FileSystemException(uri=org-dartlang-untranslatable-uri:dart%3Ahtml; message=StandardFileSystem only supports file:* and data:* URIs)
#0      StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:33:7)
#1      asFileUri (package:vm/kernel_front_end.dart:659:37)
#2      writeDepfile (package:vm/kernel_front_end.dart:853:21)
<asynchronous suspension>
#3      FrontendCompiler.compile (package:frontend_server/frontend_server.dart:574:15)
<asynchronous suspension>
#4      _FlutterFrontendCompiler.compile (package:flutter_frontend_server/server.dart:43:22)
#5      starter (package:flutter_frontend_server/server.dart:182:27)
#6      main (file:///b/s/w/ir/cache/builder/src/flutter/flutter_frontend_server/bin/starter.dart:9:30)
#7      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#8      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)



FAILURE: Build failed with an exception.

* Where:
Script '/home/dimitar/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 896

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/home/dimitar/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 10s
Exception: Gradle task assembleDebug failed with exit code 1

我扑扑的医生:

/home/dimitar/flutter/bin/flutter doctor --verbose
[✓] Flutter (Channel stable, 1.20.4, on Linux, locale bg_BG.UTF-8)
    • Flutter version 1.20.4 at /home/dimitar/flutter
    • Framework revision fba99f6cf9 (преди 6 дена), 2020-09-14 15:32:52 -0700
    • Engine revision d1bc06f032
    • Dart version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    • Android SDK at /home/dimitar/Android/Sdk
    • Platform android-29, build-tools 30.0.0
    • Java binary at: /usr/local/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Android Studio (version 4.0)
    • Android Studio at /usr/local/android-studio
    • Flutter plugin version 49.0.2
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Connected device (1 available)
    • sdk gphone x86 64 arm64 (mobile) • emulator-5554 • android-x64 • Android 11 (API 30) (emulator)

• No issues found!
Process finished with exit code 0

到目前为止,我已经尝试过:

  • 将flutter更新为最新版本
  • 将依赖项更新到最新版本
  • 删除flutter / bin中的缓存文件夹,然后运行flutter doctor
  • 已删除pubspec.lock文件,然后运行flutter pub get
  • 运行flutter clean

2 个答案:

答案 0 :(得分:0)

请先尝试使用下面的方法,然后再尝试执行“到目前为止我已经尝试过”下发布的所有解决方案,如果有任何不起作用的地方,我可以通过简单注释可解决此错误的依赖项来解决此问题。我的案例 http sentry ,然后运行flutter pub get,然后取消注释依赖项,然后再次运行flutter pub get,就可以了。

答案 1 :(得分:0)

在您的pubspec中更改为http:并删除pubspec.lock文件,然后重试