Flutter 意外退出,读取依赖时出错
Posted
技术标签:
【中文标题】Flutter 意外退出,读取依赖时出错【英文标题】:Flutter has exited unexpectedly, Error reading dependency 【发布时间】:2019-01-22 07:06:04 【问题描述】:最近,当我尝试调试时,我的代码意外停止了编译。我正在运行 Flutter v0.5.1
我能想到解释这一点的唯一原因是在我将 Flutter SDK 从桌面移动到单独的文件夹之后发生这种情况。
这是我收到的错误:
Error reading dependency file C:\Users\Jake\Desktop\Other\Flutter\myproject\build\app\intermediates\flutter\debug\snapshot_blob.bin.d: java.lang.ArrayIndexOutOfBoundsException: 1
Error reading dependency file C:\Users\Jake\Desktop\Other\Flutter\myproject\build\app\intermediates\flutter\debug\snapshot_blob.bin.d: java.lang.ArrayIndexOutOfBoundsException: 1
Error reading dependency file C:\Users\Jake\Desktop\Other\Flutter\myproject\build\app\intermediates\flutter\debug\snapshot_blob.bin.d: java.lang.ArrayIndexOutOfBoundsException: 1
Oops; flutter has exited unexpectedly.
Crash report written to C:\Users\Jake\Desktop\Other\Flutter\myproject\flutter_14.log;
please let us know at https://github.com/flutter/flutter/issues.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\Jake\Desktop\flutter_windows_v0.5.1-beta\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 435
* What went wrong:
Execution failed for task ':app:flutterBuildDebug'.
> Process 'command 'C:\Users\Jake\Desktop\flutter_windows_v0.5.1-beta\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.
* Get more help at https://help.gradle.org
BUILD FAILED in 12s
Gradle build failed: 1
Exited (sigterm)
这是转储到 myproject
文件夹中的 Flutter 日志:
Flutter crash report; please file at https://github.com/flutter/flutter/issues.
## command
flutter build bundle --suppress-analytics --target C:\Users\Jake\Desktop\Other\Flutter\myproject\lib\main.dart --preview-dart-2 --filesystem-scheme org-dartlang-root --depfile C:\Users\Jake\Desktop\Other\Flutter\myproject\build\app\intermediates\flutter\debug/snapshot_blob.bin.d --asset-dir C:\Users\Jake\Desktop\Other\Flutter\myproject\build\app\intermediates\flutter\debug/flutter_assets
## exception
RangeError: RangeError (index): Invalid value: Only valid value is 0: 1
```
#0 List.[] (dart:core-patch/dart:core/growable_array.dart:141)
#1 readDepfile (package:flutter_tools/src/base/fingerprint.dart:174)
<asynchronous suspension>
#2 Fingerprinter._getPaths (package:flutter_tools/src/base/fingerprint.dart:88)
<asynchronous suspension>
#3 Fingerprinter.doesFingerprintMatch (package:flutter_tools/src/base/fingerprint.dart:60)
<asynchronous suspension>
#4 KernelCompiler.compile (package:flutter_tools/src/compile.dart:104)
<asynchronous suspension>
#5 build (package:flutter_tools/src/bundle.dart:79)
<asynchronous suspension>
#6 BuildBundleCommand.runCommand (package:flutter_tools/src/commands/build_bundle.dart:72)
<asynchronous suspension>
#7 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:344)
<asynchronous suspension>
#8 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:279)
<asynchronous suspension>
#9 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:142)
<asynchronous suspension>
#10 _rootRun (dart:async/zone.dart:1126)
#11 _CustomZone.run (dart:async/zone.dart:1023)
#12 runZoned (dart:async/zone.dart:1501)
#13 AppContext.run (package:flutter_tools/src/base/context.dart:141)
<asynchronous suspension>
#14 FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:270)
#15 CommandRunner.runCommand (package:args/command_runner.dart:194)
<asynchronous suspension>
#16 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:309)
<asynchronous suspension>
#17 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:142)
<asynchronous suspension>
#18 _rootRun (dart:async/zone.dart:1126)
#19 _CustomZone.run (dart:async/zone.dart:1023)
#20 runZoned (dart:async/zone.dart:1501)
#21 AppContext.run (package:flutter_tools/src/base/context.dart:141)
<asynchronous suspension>
#22 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:265)
<asynchronous suspension>
#23 CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:109)
#24 new Future.sync (dart:async/future.dart:222)
#25 CommandRunner.run (package:args/command_runner.dart:109)
#26 FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:174)
#27 run.<anonymous closure> (package:flutter_tools/runner.dart:59)
<asynchronous suspension>
#28 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:142)
<asynchronous suspension>
#29 _rootRun (dart:async/zone.dart:1126)
#30 _CustomZone.run (dart:async/zone.dart:1023)
#31 runZoned (dart:async/zone.dart:1501)
#32 AppContext.run (package:flutter_tools/src/base/context.dart:141)
<asynchronous suspension>
#33 runInContext (package:flutter_tools/src/context_runner.dart:43)
<asynchronous suspension>
#34 run (package:flutter_tools/runner.dart:50)
#35 main (package:flutter_tools/executable.dart:49)
<asynchronous suspension>
#36 main (file:///E:/b/build/slave/Windows_Flutter_Packaging/build/archive/flutter/packages/flutter_tools/bin/flutter_tools.dart:8)
#37 _startIsolate.<anonymous closure> (dart:isolate-patch/dart:isolate/isolate_patch.dart:277)
#38 _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:165)
```
## flutter doctor
```
[✓] Flutter (Channel beta, v0.5.1, on Microsoft Windows [Version 10.0.17134.228], locale en-GB)
• Flutter version 0.5.1 at C:\Users\Jake\Desktop\flutter_windows_v0.5.1-beta\flutter
• Framework revision c7ea3ca377 (3 months ago), 2018-05-29 21:07:33 +0200
• Engine revision 1ed25ca7b7
• Dart version 2.0.0-dev.58.0.flutter-f981f09760
[✓] android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at C:\Users\Jake\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)
• All Android licenses accepted.
[✓] Android Studio (version 3.0)
• Android Studio at C:\Program Files\Android\Android Studio
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)
[!] VS Code, 64-bit edition (version 1.25.1)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected devices (1 available)
• HTC Desire 510 • CC58XY408727 • android-arm • Android 4.4.3 (API 19)
! Doctor found issues in 1 category.
```
错误; ✗ Flutter plugin not installed; ✗ Dart plugin not installed
应该不是问题,它们都是根据 VSCode 安装的,显然,由于 flutter doctor
无法识别区分大小写的值,这个问题会影响 VSCode 上的每个人。
【问题讨论】:
你自己回答了——“读取依赖文件 C:\Users\Jake\Desktop\Other\Flutter 时出错” “✗ Dart 插件未安装应该不是问题,”在较新的 Flutter 版本中已修复。 你知道我该如何解决这个问题吗? 不确定是什么原因造成的。你试过flutter clean
吗?
没关系,我更改了目录并在控制台中运行了flutter clean
。这非常有效并解决了问题,谢谢。
【参考方案1】:
在 Günter 建议 flutter clean
后,此问题已得到修复。
【讨论】:
【参考方案2】:按照以下步骤,问题将得到修复 使用以下命令将 Flutter 频道更改为 Master
颤振通道大师
执行下面的命令
颤动运行
问题将得到解决,您的飞镖版本将被更新
【讨论】:
【参考方案3】:我在 ubuntu 20.04 中遇到了同样的问题 我将路径更改为没有空间的目录,现在问题解决了。
【讨论】:
【参考方案4】:请执行以下步骤。这对我有用。仅适用于 Mac 用户。
第 1 步:删除 Podfiles 在mac中
i) rm ios/Podfile
ii) rm ios/Podfile.lock
第 2 步:运行 flutter clean 。它将删除构建文件夹并清理项目。
第 3 步:通过 flutter run
生成 Podfile注意:不要使用 Pod init 来生成 Podfile, 因为它不会创建任何依赖项。
可选步骤 4:如果 Podfiles 已经生成,那么我们可以通过 pod install 和 pod update来更新它>。 另外请确保您在 ios 文件夹中。
i) cd ios
ii) pod install
iii) pod update
注意:请确保flutter_svg依赖项应该是flutter_svg:pubspec.yaml中的^0.18.0
【讨论】:
【参考方案5】:要修复它,请删除项目中的 /build 文件夹,错误在哪里,然后点击以下命令:
flutter clean
然后:
flutter run
【讨论】:
这是我的修复,请参阅 OP 上的 cmets。以上是关于Flutter 意外退出,读取依赖时出错的主要内容,如果未能解决你的问题,请参考以下文章