0

I've got a fresh React Native app, where I'm trying to use react-native-config:

npx react-native init RNConfigDemo
cd RNConfigDemo

yarn add react-native-config
echo "SOME_VAR="something"" > .env

I tried to add a line in my ./android/app/src/main/java/com/rnconfigdemo/MainActivity.java:

...
  return BuildConfig.SOME_VAR;
...

and I always get the following:

RNConfigDemo/android/app/src/main/java/com/rnconfigdemo/MainActivity.java:40: error: cannot find symbol
    return BuildConfig.SOME_VAR;
                                                               ^
  symbol:   variable SOME_VAR
  location: class BuildConfig
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

FAILURE: Build failed with an exception

I can access non-.env defined BuildConfig, such as BuildConfig.DEBUG, with no issues. But my defined BuildConfig properties throw the above

I've tried running npx react-native link react-native-config, despite this having been autolinked, as well as the troubleshooting guidelines.

I verified the manually linked additions were present in their respective files.

I tried adding import com.facebook.react.BuildConfig, and then import com.rnconfigdemo.BuildConfig, to no avail.

I've followed all the steps for the Android build in the package's README

What's the issue here?

2
  • what about this step - github.com/luggit/react-native-config#extra-step-for-android Commented Mar 3, 2021 at 17:19
  • @imKrishh Thanks, I thought that was part of the troubleshooting to check that. Added that and refreshed the build and cache, to no avail Commented Mar 3, 2021 at 19:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.