Capacitor support for adaptive icons
Is there adaptive icons compatibility with capacitor?
Yes, but there might be an issue.
Possible Duplicate of #108
@sfrinx It looks like adaptive icons are not yet supported for Capacitor.
@sfrinx Could you try with the latest version?
I just
- Deleted all the mipmap folders in my android src folder except for "mipmap-anydpi-v26".
- Used https://inloop.github.io/svg2android/ to convert my SVG to android xml.
- 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.
- 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.
- 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>
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.
It seems that
cordova-resis generating the wrong XML insidemipmap-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
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>
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?
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.