Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Possible to use env vars in strings.xml for style/item ? #37

Open
atinder opened this issue Sep 29, 2016 · 17 comments
Open

[Android] Possible to use env vars in strings.xml for style/item ? #37

atinder opened this issue Sep 29, 2016 · 17 comments

Comments

@atinder
Copy link

atinder commented Sep 29, 2016

App works fine when using env vars in AndroidManifest.xml but crashes when using env vars inside strings.xml

Edit: Basically my question is related to react-native-facebook-account-kit
I want to fetch following info from .env

<style name="LoginThemeYellow" parent="Theme.AccountKit">
    <item name="com_accountkit_primary_color">#f4bf56</item>
    <item name="com_accountkit_primary_text_color">@android:color/white</item>
    <item name="com_accountkit_secondary_text_color">#44566b</item>
    <item name="com_accountkit_status_bar_color">#ed9d00</item>

    <item name="com_accountkit_input_accent_color">?attr/com_accountkit_primary_color</item>
    <item name="com_accountkit_input_border_color">?attr/com_accountkit_primary_color</item>
</style>
@atinder atinder changed the title [Android] Possible to use env vars in strings.xml ? [Android] Possible to use env vars in strings.xml for style/item ? Sep 29, 2016
@justinmoon
Copy link

This would be great. Any hints on how to implement this? I could give it a try.

@prtkkmrsngh
Copy link

Its working. Tested for react-native-facebook-login!

@joncursi
Copy link

@prtkkmrsngh how'd you get it to work? I'm trying to do the same for react-native-facebook-login

@joncursi
Copy link

I'm trying to do this in a dynamic way using this package:

  <string name="facebook_app_id">appIDhere</string>

@prtkkmrsngh
Copy link

@joncursi edit strings.xml like this

<string name="facebook_app_id">@string/FACEBOOK_APP_ID</string>

Note: FACEBOOK_APP_ID should be present in .env and if you are using different files for different environment (eg. staging, production) then in them too.

@alfonsodev
Copy link

alfonsodev commented Nov 22, 2017

This is working on my computer but is not working on Bitrise build system

String.xml

<resources>
    <string name="facebook_app_id">@string/FACEBOOK_APP_ID</string>
    <string name="fb_login_protocol_scheme">@string/FACEBOOK_LOGIN_PROTOCOL_SCHEME</string>
</resources>

I have aunique .env file

FACEBOOK_APP_ID=00000001
FACEBOOK_LOGIN_PROTOCOL_SCHEME=fb00000001
:app:processReleaseResources/Users/vagrant/git/android/app/build/intermediates/res/merged/release/values/values.xml:923:36-59:  
AAPT: No resource found that matches the given
 name (at 'facebook_app_id' with value '@string/FACEBOOK_APP_ID').

Does anybody here use a build system and had similar problems ?

@fforres
Copy link

fforres commented Dec 6, 2017

Same problem here @alfonsodev
Locally it's no issue, but on a CI/CD environment (budydbuild in my case) it does not work.

Did you find any solution?

@alfonsodev
Copy link

alfonsodev commented Dec 8, 2017

@fforres Yes, in my particular case the problem was that
on the build steps I'm moving the folder after cloning it,
but mv command wasn't copying hidden files by default,
so the .env file didn't get copied and therefore the issue.
The solution was to run shopt -s dotglob before mv command so that .env gets copied over with the src files.
I hope it helps!

@sundariragavan
Copy link

Same problem here.Any update?

@lucianomlima
Copy link

Any news on that?

@mchjohn
Copy link

mchjohn commented Aug 9, 2022

Try it

<resources>
    <string name="facebook_app_id">{$FACEBOOK_APP_ID}</string>
    <string name="fb_login_protocol_scheme">{$FACEBOOK_LOGIN_PROTOCOL_SCHEME}</string>
</resources>

@Makhdoom-Sharif
Copy link

I am trying to access the string from .env in strings.xml but it shows the error: resource string/APP_NAME (aka com.APP:string/APP_NAME) not found
. Any update?

@LuizCristino
Copy link

Looks like any access to string xml results on not found only on CI. Also looking for a solution

@tkyr-hh
Copy link

tkyr-hh commented Jan 3, 2023

this issue happened to me as well but only on CircleCI pipeline, not happening in local, I don't know why

@KFrysztak
Copy link

any update on it? I am also facing the same issue. Locally it works in a perfect way but not on CI.

@tkyr-hh
Copy link

tkyr-hh commented Jan 15, 2023

@KFrysztak for me the issue is that I'm decrypting the env file in the first job of the NPM packages installation, not in the APK build job, and it turns out that the ENV file does not exist because I need it to persist in the workspace, but this is not wise, I've put the env decryption step in the APK build job, before the step of the assemble release step, and it worked as expected.

@MhtChawlaRutrust
Copy link

I am trying to access the string from .env in strings.xml but it shows the error: resource string/APP_NAME (aka com.APP:string/APP_NAME) not found . Any update?

any workaround?

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

No branches or pull requests