【发布时间】:2020-10-11 20:28:59
【问题描述】:
在 Visual Studio Code v1.46.1 中运行应用时出现主要错误
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:cleanMergeDebugAssets'.
> Unable to delete directory 'E:\ACNO\Flutter\jots_mobile\build\app\intermediates\merged_assets\debug\out'
Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory.
- E:\ACNO\Flutter\jots_mobile\build\app\intermediates\merged_assets\debug\out\flutter_assets\assets
- E:\ACNO\Flutter\jots_mobile\build\app\intermediates\merged_assets\debug\out\flutter_assets\packages\cupertino_icons
- E:\ACNO\Flutter\jots_mobile\build\app\intermediates\merged_assets\debug\out\flutter_assets\packages
- E:\ACNO\Flutter\jots_mobile\build\app\intermediates\merged_assets\debug\out\flutter_assets
* 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 50s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
这个错误在flutter clean 之后得到解决,但即使这样也会显示以下错误
下面是flutter clean的输出
Failed to remove build. A program may still be using a file in the directory or the directory itself. To find and stop such a program, see:
https://superuser.com/questions/1333118/cant-delete-empty-folder-because-it-is-used
Deleting build... 19ms
Failed to remove E:\ACNO\Flutter\jots_mobile\.dart_tool. A program may still be using a file in the directory or the directory itself. To find and stop such a program, see:
https://superuser.com/questions/1333118/cant-delete-empty-folder-because-it-is-used
Deleting .dart_tool... 21ms
Deleting Generated.xcconfig... 4ms
Deleting flutter_export_environment.sh...
即使我杀死了this answer 中提到的使用 build 和 .dart_tool 文件夹的进程,flutter clean 也会显示相同的错误
所以,现在我必须手动转到文件资源管理器并删除 build 和 .dart_tool 文件夹,这是这里的主要问题!
总结: 运行应用程序时的主要错误在flutter clean 之后得到解决,但即使这样也显示错误,所以现在我必须手动去删除 build & .dart_tool 文件夹!
问。我该如何解决这些问题?
更新:刚刚注意到这个错误发生在我使用“f5”在 VS 代码中运行我的程序时,而不是当我在终端或 Android Studio 中使用flutter run 命令时,但是一旦它“f5”发生,flutter run 命令和 Android Studio 都发生。我猜是 VS Code 中启用此“f5”快捷方式的扩展有问题!
查看这些 GitHub 问题 • flutter/flutter • fwcd/vscode-kotlin
【问题讨论】:
-
是否有任何打开的模拟器运行该应用程序,或者该应用程序仍在实际设备上运行?
-
肯定不会,因为我重启设备并尝试运行代码后也会出现此错误!
-
Android Studio 4.0 版?尝试文件 -> 使缓存无效并重新启动
-
Visual Studio Code --version 1.46.1,我确实在 Android Studio 4.0 中尝试过我的代码,在使缓存无效并重新启动后,它只能运行一次......我不能每次都这样做是时候重启应用了!
-
您找到解决此问题的方法了吗?如果可以的话可以发一下吗?当我升级到颤振 1.17.4 时,它开始发生。我也在使用 VS 代码
标签: flutter dart visual-studio-code