Error: Source Path does not exist for android icon png when building for ionic
Clash Royale CLAN TAG#URR8PPP
Error: Source Path does not exist for android icon png when building for ionic
Your system information:
Cordova CLI: 6.5.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
OS: macOS Sierra
Node Version: v6.9.5
Xcode version: Xcode 8.2.1 Build version 8C1002
I am trying to use ionic platform add android
to create an android project, but it always complains that resources/android/icon/drawable-hdpi-icon.png
does not exist. In fact it doesn't -- none of these resources exist. They can get created by ionic resources
.
ionic platform add android
resources/android/icon/drawable-hdpi-icon.png
ionic resources
However if I try to run ionic resources
without the platform, I am told to add the platform first. This leads me to essentially do something like:
ionic resources
ionic platform add android
ionic resources
ionic platform rm android
ionic platform add android
Then it works properly. Is there anything I can do to make sure the resources get properly built or referenced before adding the platform?
6 Answers
6
For me, in config.xml, path had backward slash in tag, changed it from:
<icon src="resourcesandroidicondrawable-xhdpi-icon.png" />
to:
<icon src="resources/android/icon/drawable-xhdpi-icon.png" />
This actually had to do with my configuration. If you don't specify the platform in your configuration, platform add
will create one for you. This automatically includes paths to resources that may not be there.
platform add
Update your config.xml to include the platform; even if it is empty:
<platform name="android"/>
<platform name="ios"/>
Then, platform add
will not update the platform in the config and look for resources that may not be there. You still should do ionic resources
to generate them after the fact, though.
platform add
ionic resources
In my case it was a config.xml
path issue.
config.xml
Before I had this:
<icon density="hdpi" src="res/android/ic-hdpi.png" />
but in my folder structure I have an extra folder called icon, so I change all the .png
path files to:
.png
<icon density="hdpi" src="res/icon/android/ic-hdpi.png" />
and it worked for me
may be while creating the ionic app resources not added properly simply you can do one thing install another app by using following command.
ionic start appname blank
then copy the android icons folder and paste into you current app folder this will work fine.the image missed in your project is 72*72 image.please check the resources once.
ok add that custom image name in the place of drawable-hdpi-icon.png in the config.xml file or else change the name of the custom image name to drawable-hdpi-icon.png
– Manoj Rejinthala
Feb 9 '17 at 4:19
Check the name of the splash screen and app icon. I mistaken in the name of the files. In my case the error was due to the invalid file names. I just copied and pasted the assets i.e., AppName_splash.png and icon-512.png while it should have been "splash.png" and "icon.png".
For me, this issue was due to below line in config.xml:
'<preference name="orientation" value="portrait" />'
Actually when you try to add any platform using "ionic cordova platform add android/ios", it will add respective platform and generates respective resources("icon.png" and "splash.png"). With portrait orientation, it will add only relevant resources to that orientation(i.e. ionic cordova resources does not add the landscape images if the orientation is set to portrait) and fails with "UnhandledPromiseRejectionWarning: Error: Source path does not exist: resources/android/icon/drawable-hdpi-icon.png" error.
Hence please check whether your config.xml have any preference for portrait/landscape mode.
Please remove any preference with portrait/landscape from your config.xml file before adding platform.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I want to use a custom icon that gets built from the resources, though
– Explosion Pills
Feb 8 '17 at 14:58