You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which contains the assets that match the resource-file elements in the config.xml but they are not copied into the target folders.
What is expected to happen?
I want to define: colors.xml, splash.xml, foreground.xml and monochrome.xml in my project root res folder and then have those copied across into the android platform as appropriate.
What does actually happen?
causes an error:
Android project created with cordova-android@13.0.0
Source path does not exist: @drawable/ic_launcher_foreground
The <icon> foreground, background, and monochrome expects a file resource, not a resource reference, but will accept a color reference.
So it needs to point to a PNG file or an AVD on disk, or a @color/... value.
An example based on your provided config will look something like:
<!-- Cordova already defines colors.xml, so I'm using a new name despite the Cordova Docs guide -->
<resource-filesrc="res/values/colors.xml"target="app/src/main/res/values/myColors.xml" />
<iconforeground="res/icon/android/ic_launcher_foreground.xml"background="@color/background"density="mdpi"monochrome="res/icon/android/ic_launcher_monochrome.xml" />
Don't create a <resource-file> for your foreground and monochrome, the Cordova CLI will do this behind the scenes.
Note that despite that vectors can be used on any DPI, the <icon> directive still requires the density declared. So you'll need to replicate the <icon> directive for each dpi, mdpi, hdpi, xhdpi, xxhdpi, and xxxhpdi. There is no device on market that Cordova supports that uses ldpi` so it can safely be omitted.
With that being said, I think expanding support to allow more (or all) resource references would be desirable so I'll keep this ticket open.
breautek
changed the title
Cordova Android doesn't work with adaptive icons.
Cordova Android doesn't work with resource references
Aug 9, 2024
Bug Report
Problem
The documentation is unclear. And I tried ChatGPT too. I have this config.xml in the cordova project root.
In the project root I have the
res
folder:Which contains the assets that match the
resource-file
elements in theconfig.xml
but they are not copied into the target folders.What is expected to happen?
I want to define: colors.xml, splash.xml, foreground.xml and monochrome.xml in my project root
res
folder and then have those copied across into the android platform as appropriate.What does actually happen?
causes an error:
Information
Command or Code
cordova platform remove android; cordova platform add android;
Environment, Platform, Device
I'm running cordova on Mac OS X and trying to build it for Android API v13 for emulator.
Version information
Cordova: 12.0.0 (cordova-lib@12.0.1)
cordova-android@13.0.0
Mac OS X: 14.5 (23F79)
Android Studio Koala | 2024.1.1 Patch 1
Node: v20.15.1
Checklist
The text was updated successfully, but these errors were encountered: