Search code examples
androidreact-nativeexpogoogle-playgoogle-play-console

How to add environment variable to my app in google play console


Please I have recently launch an app on google play. I have some recent updates which includes environment variables in the app. How do I add the environment variable in my app when released to google play console? I am sure there must be an answer to this on stackoverflow but it seems my search keywords aren't bringing it up. Instead I am seeing this like putting it on google cloud or sth. I don't know if there's any documentation you can redirect me to or just answer to give me a bit of direction on how and where to search on google.

Minimal reproducible step

First create a new react native app

Install the react-native-dotenv

Follow the steps in the documentation to add it to your project

Create a .env file in the root of your project .env

URL=https://stackoverflow.com

You can then read the environment variable as the following EXAMPLE:

import { URL } from '@env'
export default App(){
 return(
   <View>
     <Text>{URL}</Text>
   </View>
 )
}

Solution

  • I later found out what I was doing wrong.

    Unfortunately, when building to publish on google play, it doesn't read your .env file or any package whatsoever that helps you get access to the file on development mode.

    You have to set it (your environment variables) in your eas.json for it to be built into the app during production.