[FIXED] How do I specify an environment variable while building an Android App Bundle


It looks like App Bundle is the preferred way of doing things (over APK) so I’d like to try to use it.

I need some way to specify an ENVFILE argument for building my React Native application. This is easily done when generating APKs through ENVFILE=.env.production assembleRelease but I cannot find an equivalent for App Bundles.

In addition, the Android Studio App Bundle wizard appears to be pretty scant when it comes to specifying options for the build.

Any ideas?


Turns out it’s a pretty simple command with a little bit of setup.

In your app.build.gradle you need to have some config

signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.release


These environment variables are set in the gradle.properties


Once that’s all set up, it’s as simple as the following

ENVFILE=.env.production gradle bundleRelease

Answered By – Pinwheeler

Answer Checked By – Cary Denson (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published