Skip to content

feat(cli): Generate icons for Android when building APK #4063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fontlos
Copy link
Contributor

@fontlos fontlos commented Apr 30, 2025

When building an APK, if an icon is specified in the configuration, it will generate *dpi variants to override the default Android icon. For simple SVG files, it additionally generates Android VectorDrawable XML for anydpi. Refs #3685

The icon file is specified in the following configuration:

# Dioxus.toml
[bundle]
icon = ["path/to/icon"]

However, there are two issues:

First, I'm not sure why the icon is defined as Vec<String>. I couldn't find any usage of this field in the project as a reference, so I default to using the first element as the icon.

Second, Android appears to apply some scaling to the foreground of Android VectorDrawable XML, causing the actual icon to be enlarged and cropped. This requires adding some margin when creating the SVG. Additionally, currently the same icon file is used for both foreground and background, and only SVGs composed of simple paths are supported.

When building an APK, if an icon is specified in the configuration, it will generate `*dpi` variants to override the default Android icon. For simple SVG files, it additionally generates Android VectorDrawable XML for `anydpi`.

The icon file is specified in the following configuration:

```toml
# Dioxus.toml
[bundle]
icon = ["path/to/icon"]
```

However, there are two issues:

First, I'm not sure why the icon is defined as `Vec<String>`. I couldn't find any usage of this field in the project as a reference, so I default to using the first element as the icon.

Second, Android appears to apply some scaling to the foreground of Android VectorDrawable XML, causing the actual icon to be enlarged and cropped. This requires adding some margin when creating the SVG. Additionally, currently the same icon file is used for both foreground and background, and only SVGs composed of simple paths are supported.
@fontlos fontlos requested a review from a team as a code owner April 30, 2025 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant