react-native-dotenv: Android bundle can't read .env file

Issuehunt badges

I’m using react-native-dotenv for my Android app. When building a debug or even a release apk, my app reads the env variables correctly. All works fine. The problem is when building the bundle .aab (that one submit in Play Store). When I download my app from Play and install it my app can’t read env variables! So why it is working good with debug/release apk and not with bundle .aab? Why this happens and how to fix it?

My babel.config.js

    plugins: [
      [
        'module:react-native-dotenv',
        {
          moduleName: '@env',
          path: '.env',
        },
      ],

I use an .env file and an .env.development file

and import my env vars like this

import {MY_ENV} from '@env'

I’m using the react-native-dotenv 3.1.1, RN 0.63.3 (bare workflow) and EXPO EAS for building the bundle.


IssueHunt Summary

Backers (Total: $2.00)

  • $2.00 have been anonymously funded.

Become a backer now!

Or submit a pull request to get the deposits!

Tips

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 33 (13 by maintainers)

Most upvoted comments

Sorry, nope. I don’t have time now, but you, as the author, could create a simple project, generate the .aab file, and confirm that all envs remain undefined and try to fix this issue.

I appreciate you might be difficult day but talking like this is not cool. Open source maintainers do not owe us anything. I’m sure you didn’t mean to cause offence, but we all need to remember that open source is built mostly on passion and maintaining a project takes up a huge amount of time.

Anyway, I thought I had this problem so I made a minimal repro starting from a blank RN project. I published the AAB to to Google Play and installed it and… it worked. Then I realised my problem was elsewhere (it wasn’t picking up my .env.development file).

So I can confirm that, at least in some cases, the AAB does contain the env vars.

If you pay attention, I contributed $2. I’m from a third-world country, and dollars are not something small here. Just so you know, I lost my job because of this issue. So, what you’re saying doesn’t make any sense. I also help and contribute to the RN community in any way I can. I’m just saying that you need to be more careful when you publish final packages, test all cases like this or at least make a note. Just that.

I have issue “Unable to resolve “@env” from “App.js”” looks like this project is no more maintained

any news on this issue? because I have the same issue in my project 😮 ? I Can see that the expo build is picking up the values from env but when aab is compiled on android store , the aab file is not picking the values 😮 ? that wierd!

Hey, thank you for opening this issue! 🙂 To boost priority on this issue and support open source please tip the team at https://issuehunt.io/r/goatandsheep/react-native-dotenv/issues/302

Done. Hope you can help me with this.