capacitor-assets icon indicating copy to clipboard operation
capacitor-assets copied to clipboard

Capacitor support for adaptive icons

Open sfrinx opened this issue 5 years ago • 7 comments

Is there adaptive icons compatibility with capacitor?

sfrinx avatar Apr 20 '20 14:04 sfrinx

Yes, but there might be an issue.

Possible Duplicate of #108

iwantwin avatar Apr 20 '20 17:04 iwantwin

@sfrinx It looks like adaptive icons are not yet supported for Capacitor.

imhoffd avatar Apr 20 '20 20:04 imhoffd

@sfrinx Could you try with the latest version?

imhoffd avatar Jul 06 '20 16:07 imhoffd

I just

  1. Deleted all the mipmap folders in my android src folder except for "mipmap-anydpi-v26".
  2. Used https://inloop.github.io/svg2android/ to convert my SVG to android xml.
  3. Placed into the default created xml document call ic_launcher_foreground.xml. I think I may have had to move it from another folder into the folder above.
  4. I did have to do some maneuvering of my svg by editing it and moving the group around. http://www.clker.com/inc/svgedit/svg-editor.html seemed to be the best tool online since i didnt have to pay or export. Use the "Apply Changes" button at the top left next to edit.
  5. Changed the background of my icon with color referenced below in the values folder.
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@color/ic_launcher_background"/>
    <foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

tellybrown avatar Aug 24 '20 03:08 tellybrown

It seems that cordova-res is generating the wrong XML inside mipmap-anydpi-v26...

This is the XML generated by the tool:

<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>

Here's the one generated by Android Studio:

<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>

Changing the two XML files by fixing the "mipmap" word is enough to have the icons working.

Lazza avatar May 25 '21 15:05 Lazza

It seems that cordova-res is generating the wrong XML inside mipmap-anydpi-v26...

This is the XML generated by the tool:

<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>

Here's the one generated by Android Studio:

<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>

Changing the two XML files by fixing the "mipmap" word is enough to have the icons working.

Hi dear, I tried your solution. Additionally delete all mipmap folders before creating resources except the one ending with v26

manikandan-bambus avatar Jul 29 '21 12:07 manikandan-bambus

Adaptive icons docs mention using @drawable instead of @mipmap or @color:

<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@drawable/ic_launcher_background" />
    <foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

piotr-cz avatar Apr 28 '22 11:04 piotr-cz

the mipmap-anydpi-v26 xml files are not created correctly - they use @colour and should be @drawable as mentioned above, but also the the foreground does not seem to maintain the aspect ratio of the other generated files. Now on the New Asset tool there seems to be a way to resize, not had chance to see if these arguments can be applied to 2 drawable items, quickly tried some arguments to no avail, deleting the files for now. A flag to opt out of them would also be useful as they are not part of the typical generated sets. Maybe images-only? as they are xml files?

drewwynne0 avatar Sep 21 '22 13:09 drewwynne0

Adaptive icon support added to @capacitor/assets and there were some fixes to them I just made yesterday. If there are other issues with adaptive icons please open specific issues for those and I'll take a look, thanks.

mlynch avatar Oct 02 '22 21:10 mlynch