Gradle任务失败-depfile无效

3zwjbxry  于 2023-05-18  发布在  其他
关注(0)|答案(3)|浏览(127)

我是一个完全的初学者在所有这些和尝试半教自己,所以请给予建议一步一步。
我试图在Windows上使用Android Studio和Flutter制作一个应用程序。当我尝试通过模拟器运行我的应用程序时(我使用genymotion,因为我有Ryzen cpu),控制台显示如下:

Invalid depfile: C:\Users\me\AndroidStudioProjects\i_am_rich\.dart_tool\flutter_build\483fc1f7e1eeed45c31ebc61a3e78ae0\kernel_snapshot.d
Invalid depfile: C:\Users\me\AndroidStudioProjects\i_am_rich\.dart_tool\flutter_build\483fc1f7e1eeed45c31ebc61a3e78ae0\kernel_snapshot.d

Compiler message:
lib/main.dart:1:8: Error: Not found: 'dart:html'
import 'dart:html';
   ^
/C:/src/flutter/flutter/packages/flutter/lib/src/painting/_network_image_web.dart:64:12: Error: Method not found: 'webOnlyInstantiateImageCodecFromUrl'.
return ui.webOnlyInstantiateImageCodecFromUrl(resolved); // ignore: undefined_function
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
U
nhandled exception:
FileSystemException(uri=org-dartlang-u
ntranslatable-uri:dart%3Ahtml; message=StandardFileSystem only supports file:* and data:* URIs)
#0      StandardFileSystem.entityForUri (package:front_end/src/api_prototype/stan
dard_file_system.dart:33:7)
#1      asFileUri (package:vm/kernel_fron
t_end.dart:604:37)
#2      writeDepfile (package:vm/kernel_front_end.da
rt:799:21)
<asynchronous suspension>
#3      FrontendCompiler.comp
ile (package:frontend_server/frontend_server.dart:472:15)
<asynch
ronous suspension>
#4      _FlutterFrontendCompiler.compile (package:flutt
er_frontend_server/server.dart:38:22)
#5      starter (package:flu
tter_frontend_server/server.dart:149:27)
#6      main (file://
/C:/b/s/w/ir/cache/builder/src/flutter/flutter_frontend_server/bin/starter.dart:8:30)

#7      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:32)
#8      _Ra
wReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)

Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.

FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 780

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\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 33s
Finished with error: Gradle task assembleDebug failed with exit code 1

当我在控制台中运行flutter医生时:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.12.13+hotfix.7, on Microsoft Windows [Version 10.0.18363.592], locale 
en-AU)

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[√] Android Studio (version 3.5)
[√] Connected device (1 available)

• No issues found!

当我尝试拍打干净:

Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
Do not run this command from the root of your git clone of Flutter.

我的flutter控制台在C:\src\flutter\flutter。我真的不知道我在做什么,也不知道该如何解决这个问题,我感到有点沮丧!任何建议将是美妙的。谢谢大家。

avwztpqn

avwztpqn1#

删除该Dart.html文件并运行项目。会成功的

1tuwyuhd

1tuwyuhd2#

要使用flutter clean,请重定向(cd..)到pubspec.yaml文件所在的文件夹。我目前也面临同样的问题,但这消除了“无效的深度文件”问题。

vaqhlq81

vaqhlq813#

转到终端

Flutter clean

后清洗

Flutter pub get

相关问题