IOS it ok, but android not ok.
my file .env
URL=localhost:3000
I used to "import Config from "react-native-config" in js code
-> IOS then Config = {URL="localhost:3000" }
-> Android then Config = {}
Is there any news or workarounds on this?
I had the same issue too, fixed following some instructions provided here : https://github.com/luggit/react-native-config/issues/32
Don't forget this part https://github.com/luggit/react-native-config#extra-step-for-android on Android setup, looks like react-native link command was not adding the line automatically.
Not working, I'm waiting for the new version
You can check these codes in MainApplication.java. If it is not exist, you can add them
import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
new ReactNativeConfigPackage();
@ozsirma where are you calling new ReactNativeConfigPackage();
@hdchan, as @ozsirma wrote in MainApplication.java:
`
@Override
protected List<ReactPackage> getPackages() {
return Arrays.asList(
...
new ReactNativeConfigPackage(),
...
);
}
@ozsirma @chrusart
I am also facing same issue
It is there in MainApplication.java still it is not working in android it is giving config={}
Allright, following the above suggestions + adding this line to android/app/proguard-rules.pro solved it for me:
-keep class com.mypackage.BuildConfig { *; }
(where com.mypackage is your package name)
Basically following the readme in other words 馃槃
So to recap:
apply plugin: "com.android.application"):apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
@Override
protected List<ReactPackage> getPackages() {
return Arrays.asList(
...
new ReactNativeConfigPackage(),
...
);
}
-keep class com.mypackage.BuildConfig { *; }
(where com.mypackage is your package name)
@ozsirma Thanks, that was my problem :+1:
Thank you folks! Closing then, let me know if the problem persists.
@Sundin I still get error: package com.lugg.ReactNativeConfig does not exist
Is this package being maintained? Anyone know of an alternative?
Most helpful comment
Allright, following the above suggestions + adding this line to
android/app/proguard-rules.prosolved it for me:-keep class com.mypackage.BuildConfig { *; }(where com.mypackage is your package name)
Basically following the readme in other words 馃槃
So to recap:
apply plugin: "com.android.application"):apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"-keep class com.mypackage.BuildConfig { *; }(where com.mypackage is your package name)