无法在新设置下编译Flutter应用

时间:2019-08-04 10:50:38

标签: flutter

我重新设置了flutter,但示例应用程序无法编译。 Flutter医生还显示一切设置正确。

以下是错误:

Launching lib/main.dart on HTC Desire 820G PLUS dual sim in debug mode...
Initializing gradle...                                              1.1s
Resolving dependencies...                                           2.0s
Unhandled exception:                                                    
Crash when compiling package:hello_world/main.dart,                     
at character offset null:                                               
null:4314624: indicated size does not match file size at                
#0      BinaryBuilder.fail (package:kernel/binary/ast_from_binary.dart:98:5)
#1      BinaryBuilder._indexComponents (package:kernel/binary/ast_from_binary.dart:425:15)
#2      BinaryBuilder.readComponent (package:kernel/binary/ast_from_binary.dart:453:36)
#3      ProcessedOptions.loadComponent (package:front_end/src/base/processed_options.dart:391:10)
#4      ProcessedOptions.loadSdkSummary (package:front_end/src/base/processed_options.dart:329:32)
<asynchronous suspension>                                               
#5      generateKernelInternal.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:71:36)
<asynchronous suspension>                                               
#6      withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)
<asynchronous suspension>                                               
#7      generateKernelInternal (package:front_end/src/kernel_generator_impl.dart:58:10)
<asynchronous suspension>                                               
#8      kernelForProgram.<anonymous closure> (package:front_end/src/api_prototype/kernel_generator.dart:48:28)
<asynchronous suspension>                                               
#9      CompilerContext.runWithOptions.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:134:20)
<asynchronous suspension>                                               
#10     CompilerContext.runInContext.<anonymous closure>.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:46)
#11     new Future.sync (dart:async/future.dart:224:31)                 
#12     CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:19)
#13     _rootRun (dart:async/zone.dart:1124:13)                         
#14     _CustomZone.run (dart:async/zone.dart:1021:19)                  
#15     _runZoned (dart:async/zone.dart:1516:10)                        
#16     runZoned (dart:async/zone.dart:1463:12)                         
#17     CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:121:12)
#18     CompilerContext.runWithOptions (package:front_end/src/fasta/compiler_context.dart:132:10)
#19     kernelForProgram (package:front_end/src/api_prototype/kernel_generator.dart:47:32)
<asynchronous suspension>                                               
#20     compileToKernel (package:vm/kernel_front_end.dart:309:27)       
<asynchronous suspension>                                               
#21     FrontendCompiler.compile.<anonymous closure> (package:vm/frontend_server.dart:359:56)
#22     new Future.<anonymous closure> (dart:async/future.dart:176:37)  
#23     _rootRun (dart:async/zone.dart:1120:38)                         
#24     _CustomZone.run (dart:async/zone.dart:1021:19)                  
#25     _CustomZone.runGuarded (dart:async/zone.dart:923:7)             
#26     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#27     _rootRun (dart:async/zone.dart:1124:13)                         
#28     _CustomZone.run (dart:async/zone.dart:1021:19)                  
#29     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#30     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:21:15)
#31     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)   
#32     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
#33     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)


#0      BinaryBuilder.fail (package:kernel/binary/ast_from_binary.dart:98:5)
#1      BinaryBuilder._indexComponents (package:kernel/binary/ast_from_binary.dart:425:15)
#2      BinaryBuilder.readComponent (package:kernel/binary/ast_from_binary.dart:453:36)
#3      ProcessedOptions.loadComponent (package:front_end/src/base/processed_options.dart:391:10)
#4      ProcessedOptions.loadSdkSummary (package:front_end/src/base/processed_options.dart:329:32)
<asynchronous suspension>                                               
#5      generateKernelInternal.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:71:36)
<asynchronous suspension>                                               
#6      withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)
<asynchronous suspension>                                               
#7      generateKernelInternal (package:front_end/src/kernel_generator_impl.dart:58:10)
<asynchronous suspension>                                               
#8      kernelForProgram.<anonymous closure> (package:front_end/src/api_prototype/kernel_generator.dart:48:28)
<asynchronous suspension>                                               
#9      CompilerContext.runWithOptions.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:134:20)
<asynchronous suspension>                                               
#10     CompilerContext.runInContext.<anonymous closure>.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:46)
#11     new Future.sync (dart:async/future.dart:224:31)                 
#12     CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:19)
#13     _rootRun (dart:async/zone.dart:1124:13)                         
#14     _CustomZone.run (dart:async/zone.dart:1021:19)                  
#15     _runZoned (dart:async/zone.dart:1516:10)                        
#16     runZoned (dart:async/zone.dart:1463:12)                         
#17     CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:121:12)
#18     CompilerContext.runWithOptions (package:front_end/src/fasta/compiler_context.dart:132:10)
#19     kernelForProgram (package:front_end/src/api_prototype/kernel_generator.dart:47:32)
<asynchronous suspension>                                               
#20     compileToKernel (package:vm/kernel_front_end.dart:309:27)       
<asynchronous suspension>                                               
#21     FrontendCompiler.compile.<anonymous closure> (package:vm/frontend_server.dart:359:56)
#22     new Future.<anonymous closure> (dart:async/future.dart:176:37)  
#23     _rootRun (dart:async/zone.dart:1120:38)                         
#24     _CustomZone.run (dart:async/zone.dart:1021:19)                  
#25     _CustomZone.runGuarded (dart:async/zone.dart:923:7)             
#26     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#27     _rootRun (dart:async/zone.dart:1124:13)                         
#28     _CustomZone.run (dart:async/zone.dart:1021:19)                  
#29     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#30     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:21:15)
#31     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)   
#32     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
#33     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)

Compiler failed on /home/sagar/Documents/aviabird/hello_world/lib/main.dart

FAILURE: Build failed with an exception.                                

* Where:                                                                
Script '/home/sagar/development/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 665

* What went wrong:                                                      
Execution failed for task ':app:compileflutterBuildDebugArm'.           
> Process 'command '/home/sagar/development/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 2s                                                      
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                         3.0s
Gradle task assembleDebug failed with exit code 1

Flutter Doctor输出:

[✓] Flutter(频道稳定,v1.7.8 + hotfix.4,在Linux上,语言环境为en_IN)     •/ home / sagar / development / flutter中的Flutter版本1.7.8 + hotfix.4     •Framework版本20e59316b8(2周前),2019-07-18 20:04:33 -0700     •引擎修订费001c93f     •Dart 2.4.0版

[✓] Android工具链-为Android设备开发(Android SDK版本29.0.1)     •位于/ home / sagar / Android / Sdk的Android SDK     •未配置Android NDK位置(可选;对本机性能分析支持很有用)     •平台android-29,构建工具29.0.1     •Java二进制文件,位于:/ home / sagar / development / android-studio / jre / bin / java     •Java版本OpenJDK运行时环境(内部版本1.8.0_152-release-1343-b16-5323222)     •接受所有Android许可。

[✓] Android Studio(3.4版)     •位于/ home / sagar / development / android-studio的Android Studio     •Flutter插件版本38.1.1     •Dart插件版本183.6270     •Java版本OpenJDK运行时环境(内部版本1.8.0_152-release-1343-b16-5323222)

[✓] VS代码(1.36.1版)     •VS Code位于/ usr / share / code     •Flutter扩展版本3.3.0

[✓]已连接设备(1个可用)     •192.168.56.101:5555•192.168.56.101:5555•android-x86•Android 7.1.1(API 25)

•找不到问题!

2 个答案:

答案 0 :(得分:4)

您的flutter安装的缓存文件夹似乎已损坏。

您可以在终端命令行中执行以下步骤:

rm -rf /Users/XXX/flutter/bin/cache(XXX是Mac用户)

flutter doctor -v

flutter run --release

p / s:link

答案 1 :(得分:0)

也有类似的问题。在我的情况下,其中一个导入类型。如果导入文件,则在一个导入中使用“ F”而不是“ f”。只需仔细检查所有输入(大小写,空格,下划线等)即可。