From 4281bc97fc622763f2e8e609aeee374b9e109864 Mon Sep 17 00:00:00 2001 From: Graham Smith Date: Tue, 28 Jul 2020 10:30:05 +0100 Subject: [PATCH 1/2] Only run Flipper in debug via MainApplication is debug --- android/app/src/debug/AndroidManifest.xml | 11 +++++-- .../reactnative/MainDebugApplication.java | 26 +++++++++++++++ .../rocket/reactnative/MainApplication.java | 32 ------------------- 3 files changed, 34 insertions(+), 35 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 5cf3292c247..ed773abe1ae 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 00000000000..54e268d03fb --- /dev/null +++ b/android/app/src/debug/java/chat/rocket/reactnative/MainDebugApplication.java @@ -0,0 +1,26 @@ +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) { + com.rndiffapp.ReactNativeFlipper.initializeFlipper(context, reactInstanceManager); + } +} 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 a4492f4df69..6bcc62be879 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 ReactNativeHost getReactNativeHost() { 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 From 3bde165e33e6431d018b907e228ed4b247838a01 Mon Sep 17 00:00:00 2001 From: Graham Smith Date: Thu, 30 Jul 2020 08:47:46 +0100 Subject: [PATCH 2/2] ReactNativeFlipper package rename + gradle bump --- .../java/chat/rocket/reactnative/MainDebugApplication.java | 3 +-- .../debug/java/chat/rocket/reactnative/ReactNativeFlipper.java | 2 +- android/gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/android/app/src/debug/java/chat/rocket/reactnative/MainDebugApplication.java b/android/app/src/debug/java/chat/rocket/reactnative/MainDebugApplication.java index 54e268d03fb..e6abf3b0500 100644 --- a/android/app/src/debug/java/chat/rocket/reactnative/MainDebugApplication.java +++ b/android/app/src/debug/java/chat/rocket/reactnative/MainDebugApplication.java @@ -8,7 +8,6 @@ public class MainDebugApplication extends MainApplication { @Override public void onCreate() { - super.onCreate(); initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); } @@ -21,6 +20,6 @@ public void onCreate() { * @param reactInstanceManager */ private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { - com.rndiffapp.ReactNativeFlipper.initializeFlipper(context, 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 07e08afd499..42eaf35c821 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/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index e603f2a5170..7578b974b4e 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