11package com .projectname ;
22
33import android .app .Application ;
4- import android .util .Log ;
54import android .content .Context ;
65import com .facebook .react .PackageList ;
7- import com .facebook .hermes .reactexecutor .HermesExecutorFactory ;
8- import com .facebook .react .bridge .JavaScriptExecutorFactory ;
96import com .facebook .react .ReactApplication ;
7+ import com .facebook .react .ReactInstanceManager ;
108import com .facebook .react .ReactNativeHost ;
119import com .facebook .react .ReactPackage ;
1210import com .facebook .soloader .SoLoader ;
1513
1614public class MainApplication extends Application implements ReactApplication {
1715
18- private final ReactNativeHost mReactNativeHost = new ReactNativeHost (this ) {
19- @ Override
20- public boolean getUseDeveloperSupport () {
21- return BuildConfig .DEBUG ;
22- }
16+ private final ReactNativeHost mReactNativeHost =
17+ new ReactNativeHost (this ) {
18+ @ Override
19+ public boolean getUseDeveloperSupport () {
20+ return BuildConfig .DEBUG ;
21+ }
2322
24- @ Override
25- protected List <ReactPackage > getPackages () {
26- @ SuppressWarnings ("UnnecessaryLocalVariable" )
27- List <ReactPackage > packages = new PackageList (this ).getPackages ();
28- // Packages that cannot be autolinked yet can be added manually here, for example:
29- // packages.add(new MyReactNativePackage());
30- return packages ;
31- }
23+ @ Override
24+ protected List <ReactPackage > getPackages () {
25+ @ SuppressWarnings ("UnnecessaryLocalVariable" )
26+ List <ReactPackage > packages = new PackageList (this ).getPackages ();
27+ // Packages that cannot be autolinked yet can be added manually here, for example:
28+ // packages.add(new MyReactNativePackage());
29+ return packages ;
30+ }
3231
33- @ Override
34- protected String getJSMainModuleName () {
35- return "index" ;
36- }
37- };
32+ @ Override
33+ protected String getJSMainModuleName () {
34+ return "index" ;
35+ }
36+ };
3837
3938 @ Override
4039 public ReactNativeHost getReactNativeHost () {
@@ -45,23 +44,28 @@ public ReactNativeHost getReactNativeHost() {
4544 public void onCreate () {
4645 super .onCreate ();
4746 SoLoader .init (this , /* native exopackage */ false );
48- initializeFlipper (this ); // Remove this line if you don't want Flipper enabled
47+ initializeFlipper (this , getReactNativeHost (). getReactInstanceManager ());
4948 }
5049
5150 /**
52- * Loads Flipper in React Native templates.
51+ * Loads Flipper in React Native templates. Call this in the onCreate method with something like
52+ * initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
5353 *
5454 * @param context
55+ * @param reactInstanceManager
5556 */
56- private static void initializeFlipper (Context context ) {
57+ private static void initializeFlipper (
58+ Context context , ReactInstanceManager reactInstanceManager ) {
5759 if (BuildConfig .DEBUG ) {
5860 try {
5961 /*
60- We use reflection here to pick up the class that initializes Flipper,
62+ We use reflection here to pick up the class that initializes Flipper,
6163 since Flipper library is not available in release mode
6264 */
63- Class <?> aClass = Class .forName ("com.facebook.flipper.ReactNativeFlipper" );
64- aClass .getMethod ("initializeFlipper" , Context .class ).invoke (null , context );
65+ Class <?> aClass = Class .forName ("com.projectname.ReactNativeFlipper" );
66+ aClass
67+ .getMethod ("initializeFlipper" , Context .class , ReactInstanceManager .class )
68+ .invoke (null , context , reactInstanceManager );
6569 } catch (ClassNotFoundException e ) {
6670 e .printStackTrace ();
6771 } catch (NoSuchMethodException e ) {
0 commit comments