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

Run assembleRelease with different configs per flavour #438

Open
altany opened this issue Mar 27, 2020 · 6 comments
Open

Run assembleRelease with different configs per flavour #438

altany opened this issue Mar 27, 2020 · 6 comments

Comments

@altany
Copy link

altany commented Mar 27, 2020

We setup our project to have two built types, debug and release, and two flavours, dev and production.

I would like to run assembleRelease to build both flavours at the same time and have each one load its own config file.

project.ext.envConfigFiles = [
    dev: ".env",
    production: ".env.production"
]

Right now I am only able to run assembleDevRelease and assembleProductionRelease successfully, as Dev and Production are recognised as flavours and the config files are read correctly.

However, if I run assembleRelease, the flavour is read as Release and both .apks use the default .env file, which is wrong.

Is there a way to write the envConfigFiles array to get this done?

Looking at the code there seems to be no way to read two different configs in one go (one per flavour), but if I get some guidance I am happy to look into it myself and maybe create a PR.

@altany altany changed the title Run assembleRelease with different configs per flavor Run assembleRelease with different configs per flavour Mar 27, 2020
@arcollector
Copy link

arcollector commented May 9, 2020

try

project.ext.envConfigFiles = [
    devrelease: ".env",
    productionrelease: ".env.production"
]

@victorkvarghese
Copy link

victorkvarghese commented Sep 9, 2020

@arcollector Thanks a lot, able to end my 8 hour web search journey
#490

@altany
Copy link
Author

altany commented Sep 9, 2020

Nope unfortunately nothing worked. @arcollector 's solution did not solve the problem, as the flavour is still read wrong as Release. Instead I am running assembleDevRelease and assembleProductionRelease to make sure the flavour is always set correctly.

@victorkvarghese
Copy link

victorkvarghese commented Sep 9, 2020

@altany ok .. for my case flavorname+buildtype name worked
#490

@arcollector
Copy link

@altany also try to add an empty string as fallback mechanism

ie

project.ext.envConfigFiles = [
    debug: '.env.development',
    release: '.env.production',
    "": '.env.development',
]
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

@gauravprwl14
Copy link

any update ?

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

4 participants