From cba6aba2e6cee3b7b444412af085e29e4d09c819 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Fri, 5 Feb 2021 11:45:28 -0800 Subject: [PATCH] Add @DoNotStrip annotation to getConstants() Summary: NativeModule getConstants() methods on Java might not be used within Java. So, they can be stripped by proguard. This diff adds the DoNotStrip annotation to the getConstants() method. Changelog: [Internal] Reviewed By: keoskate Differential Revision: D26265874 fbshipit-source-id: b405ee32406e829212e5c9641750a6b5795899c3 --- .../src/generators/modules/GenerateModuleJavaSpec.js | 1 + .../__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js index 3f7f8189749..04c39024e16 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js @@ -339,6 +339,7 @@ function buildGetConstantsMethod( return ` protected abstract Map getTypedExportedConstants(); @Override + @DoNotStrip public final @Nullable Map getConstants() { Map constants = getTypedExportedConstants(); if (ReactBuildConfig.DEBUG || ReactBuildConfig.IS_INTERNAL_BUILD) { diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap index 5e314758e47..f7654f6e4c3 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap @@ -262,6 +262,7 @@ public abstract class NativeSampleTurboModuleSpec extends ReactContextBaseJavaMo protected abstract Map getTypedExportedConstants(); @Override + @DoNotStrip public final @Nullable Map getConstants() { Map constants = getTypedExportedConstants(); if (ReactBuildConfig.DEBUG || ReactBuildConfig.IS_INTERNAL_BUILD) {