java-james / flutter_dotenv

Loads environment variables from `.env`.
https://pub.dartlang.org/packages/flutter_dotenv
MIT License
220 stars 47 forks source link

using flutter dotenv for build release #16

Open hnexokonkwo opened 4 years ago

hnexokonkwo commented 4 years ago

How can I use this library to build releases for android and ios? the environment variable does not seem to work after building apk release version

java-james commented 3 years ago

Can you confirm the .env file is included in the bundle? Typically you will add the .env file with the desired environment config as part of the build.

arnaudelub commented 3 years ago

same thing seems to happen with flutter build web. the .env file is present in build/web/assets/.env But as per the docs, .env should be declared in ./ in pubspec.yaml:

assets:
 - .env

not sure if its the problem though

fc-ds commented 3 years ago

same issue. I also tried to add the env file into the assets directory.

gelintonx commented 3 years ago

I've got the same issue

Azzeccagarbugli commented 3 years ago

This is happening to me too unfortunately. Everything goes fine when I run in debug mode, but when I run the web build release then the error happens!

fc-ds commented 3 years ago

I notice that I had a unrelated bug. I just added the file into the assets directory and include the file in the pubspec.yaml. Worked

edcmex commented 3 years ago

i tried dropping .env in /assets, no luck.

ngxingyu commented 3 years ago

Attempted to deploy web build version on surge, the provided example with .env file in assets folder works fine: web version. Ensure that - the .env file location, - the fileName parameter in dotenv.load() and - asset filepath in pubspec.yaml, are all the same.

rairongf commented 3 years ago

During the release for iOS, the app I work on was crashing on startup on a physical device with iOS 14.6 (it was working just fine on the simulator). The application was already in production for Android.

I removed all code related to the package before iOS release build and the app did not crash anymore. Seems like the .env file was not being created.

NOTE: I was getting the variables using env['VARIABLE_NAME'] within the code.

andredealmei commented 3 years ago

removed the dot from the start of file name resolve for me. from ".env" to "env"

shatanikmahanty commented 2 years ago

removed the dot from the start of file name resolve for me. from ".env" to "env"

This should be included in documentation. The documentation and the default parameter both suggest to name the file .env but the naming causes issue in flutter web

lbk9 commented 2 years ago

Using the above suggestion does not resolve issue of the package not working on release mode for iOS or Android.

Akisan98 commented 2 years ago

I have it working while running in dev and profile, but it doesnt work in release mode.

lcsvcn commented 2 years ago

same issue, works fine on debug. On android release it does not work at all.

martinfrouin commented 2 years ago

Seems working on the last version 5.0.2 with Flutter 3.0.1

teamnadanzz commented 2 years ago

Check if you have added
<uses-permission android:name="android.permission.INTERNET" /> in your Androidmanifest.xml

auaicn commented 1 year ago

Check if you have added <uses-permission android:name="android.permission.INTERNET" /> in your Androidmanifest.xml

It was cause for me...

shroot91 commented 1 year ago

removed the dot from the start of file name resolve for me. from ".env" to "env"

It worked ! Thanks a lot!

edzzn commented 6 months ago

removed the dot from the start of file name resolve for me. from ".env" to "env"

I had a similar issue building a Flutter module. It work fine for iOS, but it was not working for Android. This solved the issue.

KanhaKorgaonkar commented 4 months ago

thank you so much! this saved my life.

xamiell commented 2 months ago

removed the dot from the start of file name resolve for me. from ".env" to "env"

This solve my issue. Some systems treat files that start with a "dot" in a special way. This is the case with github actions, for example.