'Error: Source path does not exist: resources\android\icon\drawable-hdpi-icon.png

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 this error

"Error: Source path does not exist: resources\android\icon\drawable-hdpi-icon.png"

. Anyone knows where it might come from?

Here is the copy of the config.xml file :

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.ionicframework.rise268787" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>RISE</name>
<description>
    Discover music as you go
</description>
<author email="[email protected]" href="http://olivierlam.fr/">
  Olivier Lam
</author>
<content src="index.html" />
<access origin="*" />
<preference name="webviewbounce" value="false" />
<preference name="UIWebViewBounce" value="false" />
<preference name="DisallowOverscroll" value="true" />
<preference name="SplashScreen" value="screen" />
<preference name="orientation" value="portrait" />
<preference name="SplashScreenDelay" value="1000" />
<preference name="android-minSdkVersion" value="16" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="1000" />
<feature name="StatusBar">
    <param name="ios-package" onload="true" value="CDVStatusBar" />
</feature>
<platform name="android">
    <preference name="android-minSdkVersion" value="23" />
    <preference name="android-targetSdkVersion" value="23" />
    <icon density="ldpi" src="resources\android\icon\drawable-ldpi-icon.png" />
    <icon density="mdpi" src="resources\android\icon\drawable-mdpi-icon.png" />
    <icon density="hdpi" src="resources\android\icon\drawable-hdpi-icon.png" />
    <icon density="xhdpi" src="resources\android\icon\drawable-xhdpi-icon.png" />
    <icon density="xxhdpi" src="resources\android\icon\drawable-xxhdpi-icon.png" />
    <icon density="xxxhdpi" src="resources\android\icon\drawable-xxxhdpi-icon.png" />
    <splash density="port-ldpi" src="resources\android\splash\drawable-port-ldpi-screen.png" />
    <splash density="port-mdpi" src="resources\android\splash\drawable-port-mdpi-screen.png" />
    <splash density="port-hdpi" src="resources\android\splash\drawable-port-hdpi-screen.png" />
    <splash density="port-xhdpi" src="resources\android\splash\drawable-port-xhdpi-screen.png" />
    <splash density="port-xxhdpi" src="resources\android\splash\drawable-port-xxhdpi-screen.png" />
    <splash density="port-xxxhdpi" src="resources\android\splash\drawable-port-xxxhdpi-screen.png" />
</platform>
<platform name="ios">
    <icon height="57" src="resources/ios/icon/icon.png" width="57" />
    <icon height="114" src="resources/ios/icon/[email protected]" width="114" />
    <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
    <icon height="80" src="resources/ios/icon/[email protected]" width="80" />
    <icon height="120" src="resources/ios/icon/[email protected]" width="120" />
    <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
    <icon height="100" src="resources/ios/icon/[email protected]" width="100" />
    <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
    <icon height="120" src="resources/ios/icon/[email protected]" width="120" />
    <icon height="180" src="resources/ios/icon/[email protected]" width="180" />
    <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
    <icon height="144" src="resources/ios/icon/[email protected]" width="144" />
    <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
    <icon height="152" src="resources/ios/icon/[email protected]" width="152" />
    <icon height="167" src="resources/ios/icon/[email protected]" width="167" />
    <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
    <icon height="58" src="resources/ios/icon/[email protected]" width="58" />
    <icon height="87" src="resources/ios/icon/[email protected]" width="87" />
    <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
    <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
    <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
    <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
    <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
    <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
    <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
</platform>
<icon src="resources/ios/icon/[email protected]" />
<plugin name="cordova-plugin-facebook4" spec="~1.7.1">
    <variable name="APP_ID" value="XXXXXXX" />
    <variable name="APP_NAME" value="Rise" />
</plugin>
<allow-intent href="mailto:*" />
<allow-navigation href="*.youtube.com" />
<plugin name="cordova-plugin-whitelist" spec="~1.2.2" />

Thanks for your help.



Solution 1:[1]

I had the same error, After running

ionic resources

Or

ionic cordova resources

(Based on the ionic version of your application)

it went away.

The problem was that I had Windows-style slashes (backslashes) in the path of the icon, i.e. the error I had was this:

Error: Source path does not exist: resources\android\icon\drawable-hdpi-icon.png

So, converting backslashes into slashes resolved it for me.

Hope this help to you and the others looking for same problem. It all happens because using different machines[mac & windows] for development of project like mac and windows.

Solution 2:[2]

You can add your resources again by running:

ionic integrations enable cordova --add

Solution 3:[3]

The problem is because you have:

<preference name="Orientation" value="portrait" />

in your config.xml, and when you run ionic cordova resources it is only generating the resources for portrait orientation.

Solution 4:[4]

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.

Solution 5:[5]

In config.xml, I changed the resources/android/icon/drawable-hdpi.png to resources resources\android\icon\drawable-hdpi.png

Note the slash change.

Solution 6:[6]

Remove all the resources tags from the config.xml and run ionic cordova resources -f. It will auto-generate all your necessary resources and tags. And you should be able to build the app.

Solution 7:[7]

I resolved the error using the way similar to Fakan. You just need to change the icon tag with src="resources\android\icon\drawable-hdpi.png" outside the platform tags to "resources\icon.png" to resolve this error

Solution 8:[8]

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

Solution 9:[9]

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".

Solution 10:[10]

Just remove <preference name="Orientation" value="portrait" /> in config.xml file and run ionic cordova resources.

Problem is when you run ionic cordova resources it is only generates the resources for portrait orientation.

Solution 11:[11]

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.

Solution 12:[12]

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

Solution 13:[13]

The way I solved this problem worked, but it is a little peculiar.

I created the following files and put them in the "resources" directory:

icon.png, icon.jpg, icon.jpeg, splash.png, splash.jpg, splash.jpeg.

If you use --verbose, it'll tell you the dimensions each file must have. For example, icon.png must have 512x512 pixels. And splash.png must have 1920x1920 pixels.

Solution 14:[14]

In my case, I just need to change my JAVA_HOME and JRE_HOME which are supported by the Ionic project in environment variables then the error was gone.

Solution 15:[15]

In config.xml, I changed the resources\android\icon\drawable-hdpi.png to resources resources\android\icon\drawable-hdpi.png