Giter Site home page Giter Site logo

Comments (10)

barbogast avatar barbogast commented on September 24, 2024 5

I think I understand better:

If I run react-native run-android --variant staging the correct environment file is loaded. But then the command exits with the error Task 'installStaging' is ambiguous in root project 'my_app'.

When I run react-native run-android --variant stagingDebug the command runs successful, but with the default .env file.

So it looks like react-native run --variant needs flavor + buildType which is not understood by react-native-config.

from react-native-config.

hdchan avatar hdchan commented on September 24, 2024 2

Follow up: the patch in #52 also does not work in Buddy Build when building multiple variants. They are running one command like ./gradlew assembleReleaseStaging assembleReleaseProduction to build multiple variants in one pass, but this only executes the dotenv.gradle code once for both builds. It ends up taking the staging settings for both builds.

@chase-seibert i need this as well. Not sure if or when Buddy Build will implement separate gradle runs for each variant.

from react-native-config.

pedro avatar pedro commented on September 24, 2024 1

oh, and interesting take on how we could integrate this better form inside the android Gradle config.

Guess I ended up going this way because react-native run-android doesn't seem to take an environment, although maybe there's something you can pass there to get Gradle to figure out what environment it should build..?

from react-native-config.

caseyg1204 avatar caseyg1204 commented on September 24, 2024 1

Does anyone have a work around for this on Buddy Build?

from react-native-config.

pedro avatar pedro commented on September 24, 2024

Hey! Sorry I missed this, wasn't set to watch the project for some weird reason.

I personally use a single .env file per env to keep things simpler and easier to reason (eg: there's just .env.sample, use that to generate any other, etc). I realize this is cumbersome for certain projects/styles though, so down to experiment with alternatives.

So – if I got this right – we'd keep reading from .env in the normal case, but when ENVFILE is set then we'd read from that file and fill in missing values with whatever is in .env?

from react-native-config.

freakinruben avatar freakinruben commented on September 24, 2024

I'm currently using a modified dotenv.gradle in which I use:

def envFile = project.hasProperty('envFile') ? project.get('envFile').toLowerCase() : ".env.debug"

This allows the envFile prop to be set when calling gradle with a different buildType, e.g.:
./gradlew -PenvFile=.env.production assembleReleaseProduction

I've tried to integrate into

android {
    buildTypes {
        debug {
...
        }
        releaseProduction {
...
        }
    }
}

but I couldn't figure out how, so if anyone has a more elegant solution, I'm curious to learn about it :-)

from react-native-config.

chase-seibert avatar chase-seibert commented on September 24, 2024

Seconding the proposal to support defining which env is loaded from buildTypes. I'm using Build Buddy to create builds, and it cannot set different environment variables per build type.

from react-native-config.

chase-seibert avatar chase-seibert commented on September 24, 2024

Follow up: the patch in #52 also does not work in Buddy Build when building multiple variants. They are running one command like ./gradlew assembleReleaseStaging assembleReleaseProduction to build multiple variants in one pass, but this only executes the dotenv.gradle code once for both builds. It ends up taking the staging settings for both builds.

from react-native-config.

barbogast avatar barbogast commented on September 24, 2024

@pedro

... because react-native run-android doesn't seem to take an environment...

There is a --variant switch for run-android, but react-native-config always uses the .dev file.

I'm still confused but to me it looks like ./gradlew assembleRelease already builds the different flavors using the correct env-files.

from react-native-config.

hdchan avatar hdchan commented on September 24, 2024

I created a pull request to address this: #180 @caseyg1204

from react-native-config.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.