Comments (10)
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.
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.
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.
Does anyone have a work around for this on Buddy Build?
from react-native-config.
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.
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.
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.
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.
... 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.
I created a pull request to address this: #180 @caseyg1204
from react-native-config.
Related Issues (20)
- How to import NSExceptionDomains as an environment variable?
- Variable are UNDEFINED on IOS HOT 14
- Could not find method android() for arguments [dotenv_4bgzrl46y7i0xnvnmgzr6qa4c$_run_closure1@3fa75e8b] on project ':app' of type org.gradle.api.Project.
- How to read config in Kotlin class in react native 0.73? HOT 1
- RNConfig Empty Android HOT 2
- MainApplication.kt:27:58 Type mismatch: inferred type is String but Boolean was expected HOT 1
- Not working on ReactNative 0.73 HOT 1
- Error retrieving namespace value from .env file during build process
- hey, did you find a way to make it work?
- Update the documentation HOT 3
- Issue with kotlin DSL
- ios undefined problem HOT 7
- [Question] - Is this lib abandoned?
- Compatibility of react-native-config with React Native 0.73+ HOT 1
- Visionos podspec misconfiguration resulting in build failure HOT 3
- App crashes on launch when using in `GoogleService-Info.plist` on iOS
- App crashes on android release build HOT 2
- [Question] Windows: Package.appxmanifest
- Build error on iOS app with react-native 0.73.6 HOT 1
- Update example react-native version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-config.