添加我自己的应用程序图标后,Flutter 应用程序图标不可见/为空

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

我尝试按照本教程进行操作:https://pub.dev/packages/flutter_launcher_icons

所以我在 pubspec.yaml 中设置这些键:

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_launcher_icons: "^0.14.1"

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^4.0.0

flutter_launcher_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/images/icon2.png"

并执行:

flutter clean
flutter pub get
flutter pub run flutter_launcher_icons

注意到一些过时的软件包,但我认为它应该仍然有效:

Resolving dependencies... 
Downloading packages... 
  collection 1.18.0 (1.19.0 available)
  leak_tracker 10.0.5 (10.0.7 available)
  leak_tracker_flutter_testing 3.0.5 (3.0.8 available)
  material_color_utilities 0.11.1 (0.12.0 available)
  meta 1.15.0 (1.16.0 available)
  string_scanner 1.2.0 (1.3.0 available)
  test_api 0.7.2 (0.7.3 available)
Got dependencies!
7 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.

flutter pub run flutter_launcher_icons
成功,没有任何问题。我后来测试它实际上通过让它查找不存在的文件来找到该文件,并且按预期抛出了错误:

Deprecated. Use `dart run` instead.
Building package executable... 
Built flutter_launcher_icons:flutter_launcher_icons.
  ════════════════════════════════════════════
     FLUTTER LAUNCHER ICONS (v0.14.1)                               
  ════════════════════════════════════════════
  
• Creating default icons Android
• Adding a new Android launcher icon
• Creating mipmap xml file Android

WARNING: Icons with alpha channel are not allowed in the Apple App Store.
Set "remove_alpha_ios: true" to remove it.

• Overwriting default iOS launcher icon with new icon
No platform provided

✓ Successfully generated launcher icons

执行完所有这些并在我的Android手机上通过USB调试运行应用程序后,该应用程序不再有图标(我上面所说的不可见)。在此之前,它显示了通用的颤动图标。

我用

flutter pub run flutter_launcher_icons:main
dart run flutter_launcher_icons
重复了这个过程,并且还尝试从图标中删除 Alpha 通道。这并没有改变结果。该图标是 512x512 png。

我不确定如何进一步调试这个问题。

android flutter
1个回答
0
投票

我遇到了同样的问题,但这就是我解决它的方法。

在我们项目的目录终端中运行此命令:dart run flutter_launcher_icons:generate

它将在项目的根目录中生成 flutter_launcher_icons.yaml,与 pubspec.yaml 位于同一目录中。

然后运行: flutter pub run flutter_launcher_icons 在配置 flutter_launcher_icons.yaml 后,记得在构建应用程序之前运行 flutter pub get

flutter pub 运行 flutter_launcher_icons

flutter_launcher_icons: image_path:“资产/图标/yourimage.png”

android:“launcher_icon”

image_path_android:“资产/图标/icon.png”

min_sdk_android: 21 # android min sdk min:16,默认21

adaptive_icon_background:“资产/图标/background.png”

adaptive_icon_foreground:“资产/图标/foreground.png”

ios:正确

image_path_ios:“资产/图标/icon.png”

remove_alpha_channel_ios:true 删除_alpha_ios:true

网页: 生成:真 image_path:“资产/图标/yourimage.png” 背景颜色:“#hexcode” 主题颜色:“#hexcode”

窗户: 生成:真 image_path:“资产/图标/yourimage.png” icon_size: 48 # 最小:48,最大:256,默认:48

Mac: 生成:真 image_path:“资产/图标/yourimage.png”

© www.soinside.com 2019 - 2024. All rights reserved.