Annotate HybridData with DoNotStrip (#39342)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39342

Annotate HybridData with DoNotStrip

The stack of diffs aims to introduce new features and deprecate old ones in the React Native Android architecture. The main goal is to make the architecture more stable and easier to use for developers. The changes include marking ReactPackage as NullSafe, introducing the new getModule method, introducing the WillBeDeprecatedInNewArchitecture annotation, deprecating createNativeModules and marking getModule as UnstableReactNativeAPI, and fixing a lint warning in MainReactPackage.

# This diff
This diff is adding the annotation `DoNotStrip` to the `HybridData` field in the `NativeMethodCallInvokerHolderImpl` and `CallInvokerHolderImpl` classes. This is to prevent the Android ProGuard optimizer from stripping the `HybridData` field, which is necessary for the proper functioning of the TurboModule system in React Native. Additionally, the `BUCK` file for the `core` module is updated to include the `androidx:annotation` and `com.facebook.proguard.annotations:annotations` dependencies.

changelog: [intenral] internal# Context

Reviewed By: cortinico

Differential Revision: D49077065

fbshipit-source-id: cb36c0a11bdb8f5f0f4eaa7db1f0c9dcb3be2341
This commit is contained in:
David Vacca
2023-09-14 11:13:16 -07:00
committed by Facebook GitHub Bot
parent fdae17daf9
commit a629ac4206
2 changed files with 5 additions and 2 deletions
@@ -8,6 +8,7 @@
package com.facebook.react.turbomodule.core;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
/**
@@ -16,7 +17,8 @@ import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
* pass it from CatalystInstance, through Java, to TurboModuleManager::initHybrid.
*/
public class CallInvokerHolderImpl implements CallInvokerHolder {
private final HybridData mHybridData;
@DoNotStrip private final HybridData mHybridData;
static {
NativeModuleSoLoader.maybeLoadSoLibrary();
@@ -8,6 +8,7 @@
package com.facebook.react.turbomodule.core;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.turbomodule.core.interfaces.NativeMethodCallInvokerHolder;
/**
@@ -18,7 +19,7 @@ import com.facebook.react.turbomodule.core.interfaces.NativeMethodCallInvokerHol
*/
public class NativeMethodCallInvokerHolderImpl implements NativeMethodCallInvokerHolder {
private final HybridData mHybridData;
@DoNotStrip private final HybridData mHybridData;
static {
NativeModuleSoLoader.maybeLoadSoLibrary();