Skip to content

Commit f1391e5

Browse files
authored
Include classes that extend from JNA Structure in proguard consumer rules (#6979)
Specifically, I found that `com.sun.jna.Structure` ones via `RustBuffer` that seem to be removed from Android when using [R8 fullMode][0] Fixes mozilla-mobile/reference-browser#3885 and includes upstreaming the Nimbus RustBuffer rules as well. [0]: https://developer.android.com/topic/performance/app-optimization/enable-app-optimization#full-mode
1 parent 569dc9a commit f1391e5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

proguard-rules-consumer-jna.pro

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,12 @@
44
# See https://github.com/java-native-access/jna/blob/master/www/FrequentlyAskedQuestions.md#jna-on-android
55
-dontwarn java.awt.*
66
-keep class com.sun.jna.* { *; }
7-
-keepclassmembers class * extends com.sun.jna.* { public *; }
7+
-keep class * extends com.sun.jna.* { *; }
8+
-keepclassmembers class * extends com.sun.jna.* { public *; }
9+
10+
####################################################################################################
11+
# Add explicit keep rules for Nimbus RustBuffer and related structs to avoid
12+
# overly-aggressive optimization when R8 fullMode is enabled, leading to crashes.
13+
####################################################################################################
14+
-keepattributes RuntimeVisibleAnnotations,RuntimeInvisibleAnnotations,RuntimeVisibleTypeAnnotations,RuntimeInvisibleTypeAnnotations,AnnotationDefault,InnerClasses,EnclosingMethod,Signature
15+
-keep class org.mozilla.experiments.nimbus.internal.** { *; }

0 commit comments

Comments
 (0)