From 72f7471560efd8e7ec21c0354fed18f3d43e9a10 Mon Sep 17 00:00:00 2001 From: Graham Smith Date: Thu, 30 Jul 2020 13:18:48 +0100 Subject: [PATCH] [CHORE] Only run Flipper in debug via MainApplication is debug (#2347) * Only run Flipper in debug via MainApplication is debug * ReactNativeFlipper package rename + gradle bump --- android/app/src/debug/AndroidManifest.xml | 11 +++++-- .../reactnative/MainDebugApplication.java | 25 +++++++++++++++ .../reactnative/ReactNativeFlipper.java | 2 +- .../rocket/reactnative/MainApplication.java | 32 ------------------- .../gradle/wrapper/gradle-wrapper.properties | 2 +- 5 files changed, 35 insertions(+), 37 deletions(-) create mode 100644 android/app/src/debug/java/chat/rocket/reactnative/MainDebugApplication.java diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index 5cf3292c2..ed773abe1 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -1,8 +1,13 @@ + xmlns:tools="http://schemas.android.com/tools" + package="chat.rocket.reactnative"> - + - + \ No newline at end of file diff --git a/android/app/src/debug/java/chat/rocket/reactnative/MainDebugApplication.java b/android/app/src/debug/java/chat/rocket/reactnative/MainDebugApplication.java new file mode 100644 index 000000000..e6abf3b05 --- /dev/null +++ b/android/app/src/debug/java/chat/rocket/reactnative/MainDebugApplication.java @@ -0,0 +1,25 @@ +package chat.rocket.reactnative; + +import android.content.Context; + +import com.facebook.react.ReactInstanceManager; + +public class MainDebugApplication extends MainApplication { + + @Override + public void onCreate() { + super.onCreate(); + initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); + } + + /** + * Loads Flipper in React Native templates. Call this in the onCreate method with something like + * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); + * + * @param context + * @param reactInstanceManager + */ + private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { + ReactNativeFlipper.initializeFlipper(context, reactInstanceManager); + } +} diff --git a/android/app/src/debug/java/chat/rocket/reactnative/ReactNativeFlipper.java b/android/app/src/debug/java/chat/rocket/reactnative/ReactNativeFlipper.java index 07e08afd4..42eaf35c8 100644 --- a/android/app/src/debug/java/chat/rocket/reactnative/ReactNativeFlipper.java +++ b/android/app/src/debug/java/chat/rocket/reactnative/ReactNativeFlipper.java @@ -4,7 +4,7 @@ *

This source code is licensed under the MIT license found in the LICENSE file in the root * directory of this source tree. */ -package com.rndiffapp; +package chat.rocket.reactnative; import android.content.Context; import com.facebook.flipper.android.AndroidFlipperClient; import com.facebook.flipper.android.utils.FlipperUtils; diff --git a/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java b/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java index a4492f4df..6bcc62be8 100644 --- a/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java +++ b/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java @@ -81,38 +81,6 @@ public class MainApplication extends Application implements ReactApplication, IN public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); - initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); - } - - /** - * Loads Flipper in React Native templates. Call this in the onCreate method with something like - * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); - * - * @param context - * @param reactInstanceManager - */ - private static void initializeFlipper( - Context context, ReactInstanceManager reactInstanceManager) { - 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("chat.rocket.reactnative"); - aClass - .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) - .invoke(null, context, reactInstanceManager); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } } @Override diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index e603f2a51..7578b974b 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists \ No newline at end of file