I\'m trying to get an APK file from a Ionic project with the \"cordova build --release android
\" command on a Mac and it doesn\'t work as I get
Just edit your config.xml file. Mine looks like this:
<platform name="android">
<splash density="hdpi" src="res/screen/android/screen-hdpi-landscape.png" />
<splash density="port-hdpi" src="res/screen/android/screen-hdpi-portrait.png" />
<splash density="ldpi" src="res/screen/android/screen-ldpi-landscape.png" />
<splash density="port-ldpi" src="res/screen/android/screen-ldpi-portrait.png" />
<splash density="mdpi" src="res/screen/android/screen-mdpi-landscape.png" />
<splash density="port-mdpi" src="res/screen/android/screen-mdpi-portrait.png" />
<splash density="xhdpi" src="res/screen/android/screen-xhdpi-landscape.png" />
<splash density="port-xhdpi" src="res/screen/android/screen-xhdpi-portrait.png" />
</platform>
Note that res/ is relative to the project root directory. The filenames may be different at your end.
Just try to find the path of this resource inside the Ionic structure. Sometimes, or in some versions, this path may be like this:
Your resource:
resources/android/icon/drawable-hdpi.png
Try this:
res/android/icon/drawable-hdpi.png
Check your icon if it is actually saved as ".png". Not as ".PNG". Right-click on it and hit Properties.
If it wasn't, edit your icon and save it with a file extension ".png".
Do not forget to add files in the resources
folder.
The source image for icons should ideally be at least 1024×1024px and located at resources/icon.png
. The source image for splash screens should ideally be at least 2732×2732px and located at resources/splash.png
. If you used ionic start, there should already be default Ionic resources in the resources/ directory, which you can overwrite.
You need to use this formats: .png
, .psd
, or .ai
.
You can use https://code.ionicframework.com/resources/splash.psd as a template for your splash screen and https://code.ionicframework.com/resources/icon.psd for a icon.
In config.xml, I changed the resources/android/icon/drawable-hdpi.png to resources resources\android\icon\drawable-hdpi.png
Note the slash change.
A quick alternative answer:
Error: Source path does not exist: resources\android\icon\drawable-hdpi-icon.png
Is the same as
Error: Source path does not exist: resources\android\icon\foreground-hdpi-icon.png
or
Error: Source path does not exist: resources\android\icon\background-hdpi-icon.png
And any other in that category
The command looks for base files namely icon-drawable.png | icon-foreground.png | icon-background.png
in location android/resources so the best thing is to include those images in android/resources then re-run cordova build --release android
or ionic cordova resources android
to check