运行模拟器/物理设备时无法加载图像

Posted

技术标签:

【中文标题】运行模拟器/物理设备时无法加载图像【英文标题】:Can't load images in when running emmulator/physical device 【发布时间】:2020-10-19 00:03:36 【问题描述】:

这是我得到的错误:

    Target debug_android_application failed: FileSystemException: Cannot copy file to 'X:\Flutter\projects\practice_draw_screen\build\app\intermediates\flutter\debug\flutter_assets\images/IMG_2706.jpg', path = 'X:\Flutter\projects\practice_draw_screen\images\IMG_2706.jpg' (OS Error: The process cannot access the file because it is being used by another process.
, errno = 32)
build failed.

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\Matt\Flutter\packages\flutter_tools\gradle\flutter.gradle' line: 882

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

扑医生:

    Microsoft Windows [Version 10.0.18363.900]
(c) 2019 Microsoft Corporation. All rights reserved.

X:\Flutter\projects\practice_draw_screen>flutter doctor -v
[√] Flutter (Channel stable, v1.17.4, on Microsoft Windows [Version 10.0.18363.900], locale en-CA)
    • Flutter version 1.17.4 at C:\Users\Matt\Flutter
    • Framework revision 1ad9baa8b9 (11 days ago), 2020-06-17 14:41:16 -0700
    • Engine revision ee76268252
    • Dart version 2.8.4


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at C:\Users\Matt\AppData\Local\Android\Sdk
    • Platform android-29, build-tools 29.0.3
    • ANDROID_HOME = C:\Users\Matt\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Android Studio (version 4.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 47.0.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] IntelliJ IDEA Community Edition (version 2019.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.1
    • Flutter plugin version 45.0.2
    • Dart plugin version 193.6911.31

[√] VS Code (version 1.45.1)
    • VS Code at C:\Users\Matt\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.10.2

[√] Connected device (1 available)
    • Pixel 3a • 94SAY0SNC1 • android-arm64 • Android 10 (API 29)

• No issues found!

我尝试过运行 flutter -clean,但我得到了同样的错误。在 Windows 资源管理器中,包含图像的文件夹未选中为只读,但“只读”旁边有一个填充框。当我取消选中填充框时,它会将更改应用于文件,但是当我再次查看属性时,该框已填充(不是复选标记)。

【问题讨论】:

【参考方案1】:

我最终删除了图片并使用了不同的图片,这使它工作。我不确定它为什么会这样做。

【讨论】:

以上是关于运行模拟器/物理设备时无法加载图像的主要内容,如果未能解决你的问题,请参考以下文章

无法从设备上的“文档”目录加载图像

在较旧的 iOS 模拟器上运行时 Xcode 10 测试失败 - “无法加载测试包......找不到合适的图像”

资产目录,图像未在设备上加载,但在模拟器中很好

Xcode 运行时错误无法加载“_IBBrokenImage_”

未加载颤振图像(例外:解析图像编解码器)

dyld:库未加载...原因:找不到合适的图像 Xcode Swift