Skip to content
This repository has been archived by the owner on Oct 29, 2022. It is now read-only.

Add resource-file support in config.xml #472

Open
yimingkuan opened this issue Oct 21, 2015 · 26 comments
Open

Add resource-file support in config.xml #472

yimingkuan opened this issue Oct 21, 2015 · 26 comments

Comments

@yimingkuan
Copy link

gap:config-file allows users to edit the manifest/plist file, but a common request for some users for adding custom images/strings/etc or other resource files to their PhoneGap platform projects. Common examples include overriding images added by plugins for UX purposes, string translations for different users on Android, etc.

This might only be implementable after #445 though.

@mauron85
Copy link

+1

@mauron85
Copy link

Might be helpful. The biggest impact will be for cordova plugins like phonegap-plugin-push, which allows custom icons in the drawer. However PhoneGap Build users are out of luck, till this is implemented.

http://stackoverflow.com/questions/30802589/how-to-add-native-image-with-phonegap-build
http://community.phonegap.com/nitobi/topics/can-i-add-custom-images-in-the-drawable-directory
phonegap/phonegap-plugin-push#118

Thank you.

@kentmw
Copy link

kentmw commented Oct 21, 2015

+1 this is very much needed

@benmcmaster
Copy link

+1 !!!!

@jskrepnek
Copy link

+1 - would like this so that universal links (via https://github.com/nordnet/cordova-universal-links-plugin) can be used.

@LufoX11
Copy link

LufoX11 commented Jan 17, 2016

+1 - I'm still stuck with the nasty workaround of using my app image with transparencies just because I can't add a custom image to resources directory, which phonegap-plugin-push requires for the new android layout: phonegap/phonegap-plugin-push#118

@SolveSoul
Copy link

+1

@wildabeast
Copy link
Collaborator

A beta feature was added in November that should actually solve this for Android -- its described for the purpose of translation files but should work for arbitrary images etc. Put your files in locales/android, and they'll be copied to the res/ directory of your apk, persisting any subdirectories. See this issue comment.

Example:

<www.zip>/locales/android/somedir/myimage.png --> <android_apk>/res/somedir/myimage.png
<www.zip>/locales/android/another_image.png   --> <android_apk>/res/another_image.png

@LufoX11
Copy link

LufoX11 commented Jan 19, 2016

@wildabeast thanks a lot! I keep an eye on http://phonegap.com/blog/phonegap-build/ but I'm pretty sure this was not announced. Am I wrong? This is a really key new feature!

@LufoX11
Copy link

LufoX11 commented Jan 19, 2016

it works! thanks!

@neffnet
Copy link

neffnet commented Feb 2, 2016

I'm here from the above referenced issue, trying to make a custom sound play when my app receives a push notification in the background. We build with PhoneGap Build and don't know how to place the sound files so that the OS can play them when the app is in background state. @wildabeast comment helped get our custom sound working for android devices, but as far as I know there is no solution to this problem yet for iOS.

@wildabeast
Copy link
Collaborator

@neffnet yes unfortunately no support for iOS at this time. I'd suggest creating a new issue, and perhaps reference all the pertinent issues in other projects.

@razam217
Copy link

We are trying to include a sound file in ios project, we have copied it using gulp task but it seems that ios project is not adding this file in its solution, unless we manually add it through xcode. We have tried in config.xml but in vain. If someone has any solution please share.

@razam217
Copy link

razam217 commented Aug 19, 2016

Hey Guys, I've found solution to my problem. I'm adding my custom sound file in www directory, and after that when I build my project, it is easily available in XCode www directory.
The only thing you need to do is to add a www/sound.caf path in your Push Notification sound property.
For example:
{
"message": "Text",
"sound": "www/sound.caf"
}

@gabaum10
Copy link

@razam217 FYI, this is not for the Phonegap CLI, but rather the Adobe Phonegap Build service. Your solution isn't applicable here because Phonegap build users don't need to use Xcode at all.

@razam217
Copy link

@gabaum10 May be my problem is other than yours, thats why I mentioned I've found solution to my problem...
So if anyone facing problem I was facing, can fix it with my solution...
Thanks

@jantonso
Copy link

Hi,

I'm trying to add png files like described above from:
<www.zip>/locales/android/image.png --> <android_apk>/res/image.png

But they are not being copied over when I look in the apk. I'm using phonegap build cli 5.4.1.

Any ideas as to why they aren't getting copied?

Thanks

@lunaru
Copy link

lunaru commented May 12, 2017

@razam217 For what it's worth, your answer helped me -- for some simple things the www folder is added to the project by convention so you don't need to specifically config anything to be copied over.

@Heshyo
Copy link

Heshyo commented Apr 10, 2018

Is the copy <www.zip>/locales/android/somedir/myimage.png --> <android_apk>/res/somedir/myimage.png still implemented on PGB? Using CLI 7.1.0 I can't seem to get my file copied.

I have www/locales/android/drawable/pushnotificationicon.png and I zip the content under www but I don't see my png in the generated apk.

@Heshyo
Copy link

Heshyo commented Apr 10, 2018

It looks like it used to work until CLI 7.0.1 with builder 1 but not 7.0.1 builder 2 and upward: Copy files into res/values/

Has this feature been removed or modified?

@jskrepnek
Copy link

jskrepnek commented May 7, 2018

According to the blog, support for resource-file was added with version 7.0.1 and the new builder. @wildabeast We are using 7.1.0 with the old builder. Should the existing locales approach still work?

@andersborgabiro
Copy link

Why don't you use 7.1.0 or 8.0.0? 7.0.1 is terribly old (a year) :).

@jskrepnek
Copy link

@andersborgabiro Sorry, that was a typo (I've updated). We're using version 7.1.0 with the old builder.

Have you had any luck with the resource-file element? Or the previous locales copy feature?

@andersborgabiro
Copy link

No. I use my own platform independent translation solution, that stores texts in a JS object.

@AlexPashley
Copy link

AlexPashley commented Jul 11, 2018

I've just tried to add resource-file element in config.xml with my Phonegap build v8.0.0 and build fails on android

<resource-file src="push.png" target="res/push.png" />

Build Log
Failed to install 'cordova-plugin-device': Error: ENOENT: no such file or directory, open '/AndroidManifest.xml'

See this for explanation
sampart/cordova-plugin-app-version#99 (comment)

Seen as I cant use hooks any ideas?

@postersw
Copy link

postersw commented Sep 8, 2018

If you are using PhoneGap build v 8.0.0, your resource-file directive should copy to 'app/src/main/res/:

<resource-file src="push.png" target="app/src/main/res/push.png" />

Copying to res/ will cause PhoneGap build to fail, as noted above.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests