-
Notifications
You must be signed in to change notification settings - Fork 91
fix(android): forward ExecuTorch consumer ProGuard rules #1325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
msluszniak
merged 1 commit into
software-mansion:main
from
injunchoi98:fix/android-consumer-proguard-rules
Jul 22, 2026
+52
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/react-native-executorch/android/consumer-proguard-rules.pro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Ported from ExecuTorch's official Android consumer rules: | ||
| # https://github.com/pytorch/executorch/blob/904c667007aed15e9a3bb8278aa271b479450c85/extension/android/executorch_android/consumer-proguard-rules.pro | ||
|
|
||
| # ExecuTorch Android AAR — Consumer ProGuard/R8 Rules | ||
| # | ||
| # These rules are automatically applied to any app that depends on the | ||
| # ExecuTorch AAR. They prevent R8/ProGuard from stripping classes and | ||
| # methods that are called from native (JNI) code. | ||
|
|
||
| # Keep ExecuTorch classes and members annotated with @DoNotStrip. | ||
| # Scoped to org.pytorch.executorch to avoid affecting unrelated libraries. | ||
| -keep @com.facebook.jni.annotations.DoNotStrip class org.pytorch.executorch.** { *; } | ||
| -keepclassmembers class org.pytorch.executorch.** { | ||
| @com.facebook.jni.annotations.DoNotStrip *; | ||
| } | ||
|
|
||
| # Keep all native methods across ExecuTorch packages. | ||
| # Use -keepclasseswithmembers (not -keepclasseswithmembernames) to prevent | ||
| # both shrinking and obfuscation of JNI entry points. | ||
| -keepclasseswithmembers class org.pytorch.executorch.** { | ||
| native <methods>; | ||
| } | ||
|
|
||
| # Keep HybridData fields (accessed by fbjni via reflection). | ||
| -keepclassmembers class org.pytorch.executorch.** { | ||
| com.facebook.jni.HybridData *; | ||
| } | ||
|
|
||
| # Keep ExecutorchRuntimeException and its factory/subclasses. | ||
| # These are instantiated from JNI via jni_helper.cpp. | ||
| -keep class org.pytorch.executorch.ExecutorchRuntimeException { *; } | ||
| -keep class org.pytorch.executorch.ExecutorchRuntimeException$* { *; } | ||
|
|
||
| # Keep EValue (fields and type codes accessed from native code). | ||
| -keep class org.pytorch.executorch.EValue { *; } | ||
|
|
||
| # Keep Tensor and its inner classes. The Tensor class has methods and fields | ||
| # accessed from JNI (dtypeJniCode, shape, getRawDataBuffer, nativeNewTensor). | ||
| -keep class org.pytorch.executorch.Tensor { *; } | ||
| -keep class org.pytorch.executorch.Tensor$* { *; } | ||
|
|
||
| # Keep LlmCallback interface methods (invoked from native code). | ||
| -keep interface org.pytorch.executorch.extension.llm.LlmCallback { *; } | ||
|
|
||
| # Keep AsrCallback interface methods (invoked from native code). | ||
| -keep interface org.pytorch.executorch.extension.asr.AsrCallback { *; } | ||
|
msluszniak marked this conversation as resolved.
|
||
|
|
||
| # --- react-native-executorch rules (not from upstream) --- | ||
|
|
||
| # RNE's own JNI entry point, resolved by literal descriptor from C++. | ||
| -keep class com.swmansion.rnexecutorch.ETInstaller { *; } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.