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:
Nguyen Cao Nhat Linh 2016-06-16 16:06:10 -07:00 committed by GitHub
parent d056272ae7
commit 87b5eaf034
1 changed files with 9 additions and 1 deletions

View File

@ -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 {