react-native-config: cannot find symbol

2.5k Views Asked by At

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?

0

There are 0 best solutions below