如何在Flutter应用程序上设置自定义图像图标?使用Appicon

发布于 2025-01-18 13:54:31 字数 154 浏览 0 评论 0 原文

我尝试更改 apk 上应用程序的图标,但它没有改变。我在 https://appicon.co/ 上生成了一个图标并尝试更改,但它显示了 flutter 的默认应用程序图标。

I Tried changing my app's Icon on apk but it's not changing. I generated an icon on https://appicon.co/ and try changing but it's showing flutter's default app icon.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天生の放荡 2025-01-25 13:54:31

在pubsec.yaml中

 dev_dependencies:
  flutter_launcher_icons: "^0.10.0"

flutter_icons:
  android: true
  ios: true
  image_path: "assets/icon/icon.png"
  min_sdk_android: 21 # android min sdk min:16, default 21

尝试此

flutter pub run flutter_launcher_icons:main

flutter_launcher_icons 为Android和iOS再生图标。您可以在相应的文件夹中检查它(例如,Android:app/src/main/res/drawable-xxx/ic_launcher)

Try this flutter_launcher_icons

In pubsec.yaml

 dev_dependencies:
  flutter_launcher_icons: "^0.10.0"

flutter_icons:
  android: true
  ios: true
  image_path: "assets/icon/icon.png"
  min_sdk_android: 21 # android min sdk min:16, default 21

And then run this on your terminal (from android studio)

flutter pub run flutter_launcher_icons:main

The command will regenerate icons for android and ios. You can check it in the corresponding folders (eg for android : app/src/main/res/drawable-xxx/ic_launcher)

2025-01-25 13:54:31

如果您来自未来并且在使用 flutter_launcher_icons 包时遇到困难。

2022 年 7 月,我尝试使用 flutter_launcher_icons 包(版本:“^0.9.2”),但在运行时不起作用

flutter pub run flutter_launcher_icons:main

,并得到了著名的错误 255 代码。

在谷歌上进行了一些搜索后,我发现了这个(非常短)并在这里关注了这篇文章:https://www.codewithflutter.com/how-to-change-application-launcher-icon-in-flutter/

这就是我为运行我的应用程序的设备获取启动器图标所做的事情。
这是更改应用程序启动器图标的简单三步方法。

第 1 步:

前往 https://appicon.co/ 并使用选择您的启动器图像文件。

为了获得最佳效果,它应该是1024 x 1024像素。
选择您想要为其生成应用程序图标的设备。单击“生成”按钮,将下载一个 zip 文件。

当您打开下载的 zip 文件时,它通常包含“android”和“Assets.xcassets”文件夹(假设您正在为 android 和 ios 设备生成) 。

第 2 步:

手动更改图标。

此过程只是复制和粘贴文件夹。

对于 android:

打开 AppIcons\Android 文件夹并复制所有子文件夹。
然后进入 android\app\src\main\res 文件夹并粘贴它(将现有文件替换为新文件)。

对于 ios:

打开 AppIcons 文件夹并复制 Assets.xcassets 文件夹。
然后转到 ios/Runner 并粘贴它(将现有文件替换为新文件)。

第3步:

运行命令flutter run

谢谢!

If you are coming from the future and you have difficulty using the flutter_launcher_icons package.

In July 2022, I tried using the flutter_launcher_icons package (version: "^0.9.2") but it did not work when running the

flutter pub run flutter_launcher_icons:main

and got the famous error 255 code.

After a little search on google, I came across this (very short) and followed this article here: https://www.codewithflutter.com/how-to-change-application-launcher-icon-in-flutter/.

This is what I did to get a launcher icon for the devices that my app would run on.
It's a simple 3 step method to change the app launcher icon.

Step 1:

Go to https://appicon.co/ and use select your launcher's image file.

For best results, it should be 1024 x 1024 pixels.
Select the devices for which you would like the app icon to be generated for. Click on the "Generate" button and a zip file would be downloaded.

When you open the downloaded zip file, it would normally contain the "android" and the "Assets.xcassets" folders (assuming you are generating for both android and ios devices).

Step 2:

Changing the icons manually.

This process is just copying and pasting the folders.

For android:

Open the AppIcons\Android folder and copy all the sub folders.
Then go the android\app\src\main\res folder and paste it (replace the existing file to new files).

For ios:

Open the AppIcons folder and copy the Assets.xcassets folder.
Then go the ios/Runner and paste it (replace the existing file to new files).

Step 3:

Run the command flutter run

Thank you!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文