You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用flutter_launcher_icons 0.9.2更换Flutter应用图标时遭遇FileSystemException文件找不到错误的技术求助

Fixing "Cannot open file" Error with flutter_launcher_icons 0.9.2

Hey there, let's work through this file-not-found error you're hitting. Even though the plugin says it "successfully generated" icons, the real issue is it can't locate your image file later on. Here are actionable steps to fix this:

1. Double-Check Your File Path & Project Structure

First, confirm your setup matches what the plugin expects:

  • Your dev_assets folder must live in your Flutter project root directory (right next to pubspec.yaml, not inside the android/ or ios/ folders).
  • Verify the filename and extension are 100% correct: no typos, no mismatched capitalization (even on Windows, Dart's file operations can be case-sensitive here, so News-Logos.jpg vs news-logos.jpeg will break things).
  • Both image_path and adaptive_icon_foreground point to the same file, so make sure both paths are accurate.

2. Fix File Permissions (Windows-Specific)

Windows sometimes locks files or restricts access:

  • Right-click news-logos.jpeg → Properties → Uncheck the "Read-only" box if it's ticked.
  • Ensure your user account has full read access to the dev_assets folder.

3. Clear Cache & Re-Run the Command

Corrupted cache can cause weird path glitches:

  1. Clear the pub cache first:
    flutter pub cache clean
    
  2. Reinstall dependencies:
    flutter pub get
    
  3. Run the icon generation command from your project root directory (don't execute it inside android/ or any subfolder):
    flutter pub run flutter_launcher_icons:main
    

4. Test with an Absolute Path (Troubleshooting Step)

To rule out relative path issues, temporarily use the full absolute path to your icon in pubspec.yaml:

image_path: "D:/your_full_project_path/dev_assets/news-logos.jpeg"
adaptive_icon_foreground: "D:/your_full_project_path/dev_assets/news-logos.jpeg"

If this works, switch back to the relative path—this confirms the problem was with how the plugin resolved the relative path from your working directory.

5. Try a Different Plugin Version

Version 0.9.2 has some known path-related quirks. Try downgrading to 0.9.1 or upgrading to the latest stable version:

  • Update your pubspec.yaml:
    dev_dependencies:
      flutter_test:
        sdk: flutter
      flutter_launcher_icons: ^0.9.1  # Or latest stable like ^0.13.1
    
  • Run flutter pub get and re-execute the icon generation command.

内容的提问来源于stack exchange,提问作者Arkham007

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 15:49:08