Cordova-android how to correctly declare an adaptive icon #435
Replies: 2 comments
-
If I believe If you have a source SVG vector, this is what I did.
The monochrome icon should follow the same thing as your foreground, except it should be binary colour (e.g. only white |
Beta Was this translation helpful? Give feedback.
-
After several hours of testing different ways and dozens of compilations I managed to define all the icons correctly ( <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round"/>
</edit-config>
<!-- colors include <resources><color name ="ic_launcher_background">#FFFFFF</color></resources> -->
<resource-file src="res/android/colors.xml" target="/app/src/main/res/values/colors.xml" />
<!-- import drawable -->
<resource-file src="res/android/drawable/ic_launcher_foreground.xml" target="app/src/main/res/drawable/ic_launcher_foreground.xml" />
<!-- import anydpi -->
<resource-file src="res/android/mipmap/anydpi-v26/ic_launcher.xml" target="app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" />
<!-- import rounded icons -->
<resource-file src="res/android/mipmap/anydpi-v26/ic_launcher_round.xml" target="app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml" />
<resource-file src="res/android/mipmap/hdpi/ic_launcher_round.webp" target="app/src/main/res/mipmap-hdpi/ic_launcher_round.webp" />
<resource-file src="res/android/mipmap/mdpi/ic_launcher_round.webp" target="app/src/main/res/mipmap-mdpi/ic_launcher_round.webp" />
<resource-file src="res/android/mipmap/xhdpi/ic_launcher_round.webp" target="app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp" />
<resource-file src="res/android/mipmap/xxhdpi/ic_launcher_round.webp" target="app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp" />
<resource-file src="res/android/mipmap/xxxhdpi/ic_launcher_round.webp" target="app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp" />
<!-- create icons -->
<icon monochrome="res/android/drawable/ic_launcher_foreground.xml" background="@color/ic_launcher_background" density="mdpi"
foreground="res/android/drawable/ic_launcher_foreground.xml" src="res/android/mipmap/mdpi/ic_launcher.webp"/>
<icon monochrome="res/android/drawable/ic_launcher_foreground.xml" background="@color/ic_launcher_background" density="hdpi"
foreground="res/android/drawable/ic_launcher_foreground.xml" src="res/android/mipmap/hdpi/ic_launcher.webp"/>
<icon monochrome="res/android/drawable/ic_launcher_foreground.xml" background="@color/ic_launcher_background" density="xhdpi"
foreground="res/android/drawable/ic_launcher_foreground.xml" src ="res/android/mipmap/xhdpi/ic_launcher.webp" />
<icon monochrome="res/android/drawable/ic_launcher_foreground.xml" background="@color/ic_launcher_background" density="xxhdpi"
foreground="res/android/drawable/ic_launcher_foreground.xml" src ="res/android/mipmap/xxhdpi/ic_launcher.webp" />
<icon monochrome="res/android/drawable/ic_launcher_foreground.xml" background="@color/ic_launcher_background" density="xxxhdpi"
foreground="res/android/drawable/ic_launcher_foreground.xml" src ="res/android/mipmap/xxxhdpi/ic_launcher.webp" /> |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm writing here because I can't find the discussion panel in the cordova-android branch.
I'm using version 12.0.1 and I have a problem with adaptive icons. I have read #1616, however I still can't generate a working icon.
In documentation it says that I should do:
However when I generate icons in Android Studio I get:
Monochrome is defined at
anydpi-v26
, so how should I define the<icon>
attributes? I tried importing the icons via the<resource-file>
tag and modifying the AndroidManifest without the<icon>
tag inconfig.xml
, but then I got an error thatic_launcher.webp
already exists (the default cordova icon). I also tried:But it does not work as it should. Android Studio does not generate
ldpi
. How to define it correctly?Beta Was this translation helpful? Give feedback.
All reactions