使用flutter_launcher_icons 0.9.2更换Flutter应用图标时遭遇FileSystemException文件找不到错误的技术求助
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_assetsfolder must live in your Flutter project root directory (right next topubspec.yaml, not inside theandroid/orios/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.jpgvsnews-logos.jpegwill break things). - Both
image_pathandadaptive_icon_foregroundpoint 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_assetsfolder.
3. Clear Cache & Re-Run the Command
Corrupted cache can cause weird path glitches:
- Clear the pub cache first:
flutter pub cache clean - Reinstall dependencies:
flutter pub get - 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 getand re-execute the icon generation command.
内容的提问来源于stack exchange,提问作者Arkham007

