4

在 VS 代码中构建我的颤振应用程序后,我成功运行了该应用程序,一切正常。但是在应用程序重新启动 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,再次重建,但还是一样!!

4

2 回答 2

0

这似乎是与文件权限相关的问题。尝试使用命令行复制文件。您将收到类似的错误。

复制 J:\flutter_projects\webdoc\assets\images\background.png J:\flutter_projects\webdoc\build\app\intermediates\flutter\debug\flutter_assets\assets\images\background.png

现在检查您是否对目标目录/文件具有必要的权限,或者目标文件/目录不是只读的。

块引用

参考:https ://github.com/flutter/flutter/issues/49874

于 2020-02-04T08:56:50.317 回答
-1

这个问题可以通过打开 Windows Controlled Folder Access Steps 来解决 windows cont

于 2019-12-23T05:52:22.777 回答