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

Flutter Android启动页配置问题:@mipmap/ic_launcher资源无法解析

Fixing the "@mipmap/ic_launcher Resource Not Resolved" Issue in Flutter's Android Launch Screen

Hey there! Let's tackle this frustrating issue where your launcher icon works perfectly in the AndroidManifest.xml but won't resolve in launch_background.xml. Here are the most common fixes to get your launch screen showing the icon correctly:

1. Double-Check the Icon Resource Name & Location

First, let's confirm you're referencing the right resource:

  • Navigate to android/app/src/main/res and expand all mipmap-* folders (like mipmap-hdpi, mipmap-mdpi).
  • Verify every folder contains a file named ic_launcher.png (or matching image format). Sometimes the Image Asset wizard generates a rounded version named ic_launcher_round by default—if that's the case, update your launch_background.xml to use @mipmap/ic_launcher_round instead.
  • Make sure launch_background.xml is saved directly in android/app/src/main/res/drawable (not a version-specific subfolder like drawable-v21 unless intended for targeted API levels).

2. Clear Android Studio's Cache & Rebuild

Android Studio's cached resources often cause false "resource not found" errors. Try these steps:

  • Go to the top menu bar and select Build → Clean Project to delete all compiled build files.
  • Next, select Build → Rebuild Project to recompile everything from scratch.
  • If the error persists, go to File → Invalidate Caches..., check "Clear file system cache and local history", then click Invalidate and Restart to clear deep caches and restart the IDE.

3. Verify XML Syntax & Namespace

Even a tiny typo can break resource resolution. Double-check your launch_background.xml:

  • Ensure the root layer-list tag includes the correct Android namespace:
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="center">
    
  • Confirm the bitmap tag's android:src attribute is spelled correctly:
    <bitmap android:src="@mipmap/ic_launcher" />
    

4. Confirm Flutter's Android Module Configuration

Since this is a Flutter project, make sure your launch theme is properly linked:

  • Verify the android:theme attribute in the <activity> tag points to your LaunchTheme:
    <activity
        android:name=".MainActivity"
        android:theme="@style/LaunchTheme"
        ...>
    
  • Double-check the android:icon attribute in the <application> tag uses the same @mipmap/ic_launcher reference that works for your app icon.

After trying these steps, your launch_background.xml should correctly resolve the icon resource, and your launch screen will display the icon as expected!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.06 12:38:14