构建时 Flutter 启动图标为空

问题描述 投票:0回答:1

我正在尝试向我的 Flutter 应用程序添加启动图标,目前我只关心 Android。我已经安装了 flutter_launcher_icons 包并尝试了一些不同的东西,但手机只显示一些默认的空图标(一部手机上有蓝色背景的拼图,另一部手机上只有一个黑框)。这是我的 pubspec.yaml 文件中的行:

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_launcher_icons: "^0.14.0"

flutter_launcher_icons:
  android: "launcher_icon"
  ios: false
  image_path: "assets/icon/icon.png"
  adaptive_icon_background: "#5F8F3C"
  remove_alpha_ios: true
  min_sdk_android: 21

launcher_icon 文件位于 android/app/src/main/res/ 文件夹中,并且它是正确的图像(虽然背景不存在,但我不确定它是否会在稍后处理)。 AndroidManifest.xml 文件有第

android:icon="@mipmap/launcher_icon"
行。我真的不确定这里出了什么问题。原始图像的尺寸为 512x512。

android flutter flutter-launcher-icons
1个回答
0
投票

文档中所述:

仅当同时指定

adaptive_icon_background

adaptive_icon_foreground
 时,才会生成
自适应图标。 (
image_path
不会自动作为前景)

要解决此问题,您需要在

pubspec.yaml
文件中指定 adaptive_icon_foreground

flutter_launcher_icons:
  android: "launcher_icon"
  ios: false
  image_path: "assets/icon/icon.png" 
  adaptive_icon_foreground: "assets/icon/icon.png" # Set the foreground image (same or different from image_path)
  adaptive_icon_background: "#5F8F3C"
  remove_alpha_ios: true
  min_sdk_android: 21
© www.soinside.com 2019 - 2024. All rights reserved.