在使用 VS Code 构建我的 Flutter 应用程序后,我成功地运行了应用程序,一切正常。但是,在应用程序重新启动 2 次或更多次后,每当我再次运行我的代码时,构建失败。出现以下错误提示:
Target debug_android_application failed: FileSystemException: Cannot copy file to 'J:\flutter_projects\webdoc\build\app\intermediates\flutter\debug\flutter_assets\assets\images\background.png', path = 'J:\flutter_projects\webdoc\assets\images\background.png' (OS Error: Access is denied.
, errno = 5)
build failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 780
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\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 9s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 10.2s
Gradle task assembleDebug failed with exit code 1
当第一次出现此错误时,我将当前目录中的所有文件剪切并复制到其他目录中,然后它再次正常工作。但即使现在运行2或3次后,错误仍然会弹出。是否有任何解决此问题的方法?
我尝试删除.vscode,重新构建,但仍然是相同的错误!