Fix when applicationId ≠ package name
for using applicationIdSuffix in different flavors or when applicationId is different from package name in AndroidManifest #14
This commit is contained in:
parent
d056272ae7
commit
87b5eaf034
|
@ -34,7 +34,15 @@ public class ReactNativeConfigModule extends ReactContextBaseJavaModule {
|
|||
final Map<String, Object> constants = new HashMap<>();
|
||||
|
||||
try {
|
||||
Class clazz = Class.forName(getReactApplicationContext().getPackageName() + ".BuildConfig");
|
||||
Context context = getReactApplicationContext();
|
||||
int resId = context.getResources().getIdentifier("build_config_package", "string", context.getPackageName());
|
||||
String className;
|
||||
try {
|
||||
className = context.getString(resId);
|
||||
} catch (Resources.NotFoundException e) {
|
||||
className = getReactApplicationContext().getApplicationContext().getPackageName();
|
||||
}
|
||||
Class clazz = Class.forName(className + ".BuildConfig");
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
for(Field f: fields) {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue