Res folder location in cordova - android

I am trying to add app icons to my Cordova app (android currently):
<platform name="android">
<icon src="res/icons/mipmap-ldpi/ic_launcher.png" density="ldpi" />
<icon src="res/icons/mipmap-mdpi/ic_launcher.png" density="mdpi" />
<icon src="res/icons/mipmap-hdpi/ic_launcher.png" density="hdpi" />
<icon src="res/icons/mipmap-xdpi/ic_launcher.png" density="xhdpi" />
<icon src="res/icons/mipmap-xxdpi/ic_launcher.png" density="xxhdpi" />
<icon src="res/icons/mipmap-xxxdpi/ic_launcher.png" density="xxhdpi" />
</platform>
I get the error:
Source path does not exist: res/icons/mipmap-hdpi/ic_launcher.png
I have tried multiple different paths in config.xml and tried multiple places where to actually put the images, but I haven't seen clearly in any documentation or stackoverflow questions where to actually put the icon files. They seem to need to be in a folder called res but I can't figure out where to put that folder in Cordova.
Edit:
I have tried to put the files in:
www/
www/res/
platforms/android/
platforms/android/res/
platforms/android/platform_www/
platforms/android/platform_www/res/

at the same level as www
/www
/res
/platforms/android

Related

Specify an app icon for phonegap build is not working

I'm trying to change the default Cordova app icon for both ios and android using config.xml, but the build is using the Cordova logo as an icon and splash screen.
I don't have the Cordova iOS platform installed because I'm using PhoneGap build.
Here's the icon tag in config.xml
<icon src="res/icon.png" />
I put the icon inside www/res/icon.png
Is this a correct path?
The path should point to res/android/<DENSITY_TYPE>
Here is example from DOCs:
<platform name="android">
<icon src="res/android/ldpi.png" density="ldpi" />
<icon src="res/android/mdpi.png" density="mdpi" />
<icon src="res/android/hdpi.png" density="hdpi" />
<icon src="res/android/xhdpi.png" density="xhdpi" />
</platform>
The res folder should lay under your root project, not under www

phonegap android app does not show my app icon :(

I am working on an android app with phonegap. I have tried all sorts of stuff to get my icon on the app, but have been unsuccessful. The android bot icon appears on the app when installed from apk.
I have this in config.xml:
<icon density="ldpi" src="www/res/icon/android/ldpi.png" />
<icon density="mdpi" src="www/res/icon/android/mdpi.png" />
<icon density="hdpi" src="www/res/icon/android/hdpi.png" />
<icon density="xhdpi" src="www/res/icon/android/xhdpi.png" />
<icon density="xxhdpi" src="www/res/icon/android/xxhdpi.png" />
I read http://devgirl.org/2013/09/12/phonegap-icons-and-splash-screens-help/
and the steps given here are already happening.
In my /platforms/android/res/ the desired icons and screens appear in the right drawable folder.
I dont know what i am doing wrong. cant just get the icon to show up.
I am not using the phonegap desktop app
Use the same filename (ic_launcher.png is the default and most common one) for all icons, while they are in different folders, and change your icons call in the config.xml file to this:
<icon src="folder-hdpi/ic_launcher.png"
gap:platform="android"
gap:density="hdpi"/>
<icon src="folder-mdpi/ic_launcher.png"
gap:platform="android"
gap:density="mdpi"/>
<icon src="folder-xhdpi/ic_launcher.png"
gap:platform="android"
gap:density="xhdpi"/>
<icon src="folder-xxhdpi/ic_launcher.png"
gap:platform="android"
gap:density="xxhdpi"/>
<icon src="folder-xxxhdpi/ic_launcher.png"
gap:platform="android"
gap:density="xxxhdpi"/>

Why does Phonegap replace my icon?

I've followed tutorials and solutions to Phonegap icon issues here on SO. From what I'm reading it looks like, if I'm building locally, I need to replace the PG icons in platforms/android/res/drawable (there are 3 diff folders in drawable that contain the icon) with my own. That is what I am doing. Here's where it gets weird. I replace these icons with my own (different icon, same name), then go to Terminal and do phonegap build android, and then if I navigate back to the drawables folders I see that my new icons have been replaced yet again with the default Phonegap robot icons. What am I missing?
Yes, the problem is that the platform folders are rebuilt every time you do a build or run from the PhoneGap CLI so you don't want to replace them in there manually. Instead you should keep them in a folder somewhere in the root of your project (named whatever you'd like), then refer to their paths in the config.xml file for the given platform. The PhoneGap CLI will will copy them down to the platform level for you automatically when you do a build, run etc. For Android it will copy them down to the platforms/android/res/drawable* folders specifically based on their density (ldpi etc). You just need to make sure you specify the right density attributes in the config.xml (or width/height for iOS) to match the correct paths in your root project where those can be found.
For instance, in the config.xml you may have the following for Android icons:
<platform name="android">
<icon density="ldpi" src="resources/android/ldpi-icon.png" />
<icon density="mdpi" src="resources/android/mdpi-icon.png" />
<icon density="hdpi" src="resources/android/hdpi-icon.png" />
<icon density="xhdpi" src="resources/android/xhdpi-icon.png" />
<icon density="xxhdpi" src="resources/android/xxhdpi-icon.png" />
<icon density="xxxhdpi" src="resources/android/xxxhdpi-icon.png" />
</platform>
Where resources is located in the root of your project at the same level as the www folder (ie: myProj/resources).
You can find more details about this in the Cordova docs for more details on configuring your icons.
If for some reason it doesn't work, check to make sure you have a recent version of the PhoneGap CLI or update to the latest.
~Holly
You have to add the icon configuration in you config.xml file inside your www root folder. Try adding something like this:
<platform name="android">
<icon src="res/android/ldpi.png" density="ldpi" />
<icon src="res/android/mdpi.png" density="mdpi" />
<icon src="res/android/hdpi.png" density="hdpi" />
<icon src="res/android/xhdpi.png" density="xhdpi" />
</platform>
The create these folders containing your icons and execute phonegap build android.
The answer was in fact to use this code block in config.xml at the root level (same level as www directory):
<icon src="www/res/icon/android/ldpi.png" platform="android" density="ldpi" />
<icon src="www/res/icon/android/mdpi.png" platform="android" density="mdpi" />
<icon src="www/res/icon/android/hdpi.png" platform="android" density="hdpi" />
<icon src="www/res/icon/android/xhdpi.png" platform="android" density="xhdpi" />
<icon src="www/res/icon/android/xxhdpi.png" platform="android" density="xxhdpi" />
<icon src="www/res/icon/android/xxxhdpi.png" platform="android" density="xxxhdpi"/>
Making sure, obviously, that those paths lead to your icons.

Additional icons with cordova config.xml

I am using the local notifications plugin (Android) and I would like to add the notification-icons using the config.xml
For example I have a png file:
ic_stat_music_play
ic_stat_music_pause
As I need to add the files to the different drawable folders in the same way as I add the icons/splash, I would like to know if I can add the files using the config.xml
For example I add the icon for hdpi like this:
<icon src="assets/icon/android/drawable-hdpi/icon.png" density="hdpi" />
So far I tried:
<ic_stat_music_play src="assets/icon/android/drawable-hdpi/ic_stat_music_play.png" platform="android" density="hdpi" />
<ic_stat_black_call src="assets/icon/android/drawable-hdpi/ic_stat_music_play.png" platform="android" qualifier="hdpi" />
<gap:ic_stat_black_call src="assets/icon/android/drawable-hdpi/ic_stat_music_play.png" gap:platform="android" gap:density="hdpi" />
But none works so far.
Any idea how this might work?

Phonegap CLI: "Upload failed You need to add an icon to your APK phonegap"

I have created an application for upload in with phonegap 3.5.0. I used the "Icons and Splash Screens" guide to create application icons, and they show up when running through debugging in the AVD and my phone. When I create the APK for upload to Google Play, however, I am prompted with "Upload failed
You need to add an icon to your APK."
What do I need to change the manifest file to in order for the be able to upload? Or is the error somewhere else? Thanks in advance for your help.
In your config.xml file > add your icons
Make sure that you placed the icon image in the folder res/android/
<platform name="android">
<icon src="res/android/ldpi.png" density="ldpi" />
<icon src="res/android/mdpi.png" density="mdpi" />
<icon src="res/android/hdpi.png" density="hdpi" />
<icon src="res/android/xhdpi.png" density="xhdpi" />
</platform>
for more information http://docs.phonegap.com/en/3.5.0/config_ref_images.md.html

Categories

Resources