React-native-config: Doesn't Work

Created on 22 Dec 2016  路  5Comments  路  Source: luggit/react-native-config

Sorry for the terse subject, but I don't know what else to say.

To install I ran:

yarn add react-native-config
react-native link react-native-config

I have .env file in my root folder:

API_URL=http://192.168.1.175:8080/graphql

At the entry point of my app I have:

import Config from 'react-native-config';
console.log(Config);

Which outputs:

APPLICATION_ID: "com.myapp"
BUILD_TYPE: "debug"
DEBUG: true
FLAVOR: ""
VERSION_CODE: 1
VERSION_NAME: "1.0"

And Config.API_URL is undefined.

Same result on iOS and Android. It seems dead simple, and I can't see what could be wrong other than a bug. Ideas?

Most helpful comment

Hi Tim! did you add apply from... to your Gradle config as mentioned here?
https://github.com/luggit/react-native-config#extra-step-for-android

All 5 comments

Sorry, correction. It does work on iOS after react-native run-ios. No luck on Android after restarting the simulator, clearing cache and repackaging.

Hi Tim! did you add apply from... to your Gradle config as mentioned here?
https://github.com/luggit/react-native-config#extra-step-for-android

@pedro I just noticed that from another issue. Thanks. Might be good to add that to the linking if possible or make it more prominent in doc since it's not optional.

Sweet, thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

p-grzelczak picture p-grzelczak  路  5Comments

ORESoftware picture ORESoftware  路  3Comments

joncursi picture joncursi  路  4Comments

Quadriphobs1 picture Quadriphobs1  路  3Comments

NachtRitter picture NachtRitter  路  4Comments