diff --git a/android/app/src/main/java/com/zulipmobile/MainApplication.java b/android/app/src/main/java/com/zulipmobile/MainApplication.java index 3bafe0f5b1b..383233bd0c8 100644 --- a/android/app/src/main/java/com/zulipmobile/MainApplication.java +++ b/android/app/src/main/java/com/zulipmobile/MainApplication.java @@ -1,6 +1,7 @@ package com.zulipmobile; import android.app.Application; +import android.content.Context; import android.util.Log; import com.facebook.react.PackageList; @@ -10,6 +11,7 @@ import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.soloader.SoLoader; +import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.List; import org.unimodules.adapters.react.ModuleRegistryAdapter; @@ -77,4 +79,30 @@ public void onCreate() { SoLoader.init(this, /* native exopackage */ false); conversations = new ConversationMap(); } + + /** + * Loads Flipper in React Native templates. + * + * @param context + */ + private static void initializeFlipper(Context context) { + if (BuildConfig.DEBUG) { + try { + /* + We use reflection here to pick up the class that initializes Flipper, + since Flipper library is not available in release mode + */ + Class aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper"); + aClass.getMethod("initializeFlipper", Context.class).invoke(null, context); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + } }