On 17 Nov 2026 the Android Developers blog asked library authors to stop shipping package-wide keep rules, because the DEX code optimization insights in Play Console count the rules your libraries bundle against your app. We unpacked the current npm releases of 35 popular React Native libraries and classified every consumer keep rule they ship. The takeaway: 14 of the 35 ship consumer rules, and 7 of those keep whole packages (15 rules in total). Two of them, react-native-reanimated 4.7.2 and react-native-worklets 0.13.1, keep all of React Native’s own com.facebook.react.fabric and com.facebook.react.turbomodule packages in any app that installs them.
This is a source audit: npm pack of each library on 18 Nov 2026, a 22-line script over the android/ folders, and the rule files read by hand. No app was built, so this post makes no claims about APK size.
Why we did this: the banking app we build ships with R8 full mode, and React Native pulls dozens of Android libraries in through npm. We wanted to know which of them limit what R8 can do before the Play Console insight shows up on our own listing.
What Google is asking for
The post, by Breana Tate, is short and specific. Package-wide rules “aren’t recommended as a long term solution for crash prevention”, and the example it gives is the familiar -keep public class com.google.android.gms.** { *; }. The library optimization guide (updated 12 Nov 2026) turns this into rules for library authors:
- “Don’t include package-wide keep rules (such as
-keep class com.mylibrary.** {*; }).” - “Don’t include broad keep rules for third-party dependencies that your library consumes.”
- “Never use global options like
-dontobfuscateor-allowaccessmodification.” From AGP 9.0, publishing a library fails by default if its consumer rules contain global options. - “When possible, use code generation (codegen) over reflection.”
- “If your library crashes under R8, the solution is to identify the specific reflection or JNI entry point and add a targeted rule, not to keep the entire package.”
The blog adds two points that matter for React Native: “provide rules for all classes that use JNI”, and avoid keepnames for readable stack traces, because uploading the mapping file gives you those without blocking optimization.
How we audited the libraries
We packed the newest release of each library from npm (for react-native-webview we took 17.1.0, the next tag, since latest still points at 14.0.1). Then a short script finds every file named in consumerProguardFiles in the Gradle build, strips comments and sorts each rule into one bucket:
- package-wide: a
.**wildcard with{ *; }, which keeps every class and member in the package tree - class-wide: one class or all implementers of a type, with
{ *; } - member-level: names specific fields, methods or constructors
- conditional: an
-ifrule - names only:
-keepnamesand friends, which allow shrinking but block renaming - global: options such as
-keepattributesor-dontobfuscate
import re, sys, pathlib
# usage: keep_audit.py <unpacked-package-dir>...
KIND = [("conditional", r"^-if\b"),
("names only", r"^-keep(class(es)?with)?(member)?names\b"),
("global", r"^-(dontobfuscate|dontoptimize|dontshrink|keepattributes|repackageclasses|allowaccessmodification)\b")]
def classify(rule):
for k, rx in KIND:
if re.match(rx, rule): return k
if not rule.startswith("-keep"): return "other"
wide = re.search(r"\{\s*\*;?\s*\}", rule)
if "**" in rule.split("{")[0] and wide: return "package-wide"
if wide: return "class-wide"
return "member-level"
for pkg in sys.argv[1:]:
for gradle in pathlib.Path(pkg).rglob("build.gradle*"):
for f in re.findall(r"consumerProguardFiles\s*\(?\s*['\"]([^'\"]+)", gradle.read_text()):
text = (gradle.parent / f).read_text()
text = re.sub(r"#.*", "", text)
rules = re.findall(r"^-[^{\n]*(?:\{[^}]*\})?", text, re.M)
for r in rules:
r = " ".join(r.split())
print(f"{pathlib.Path(pkg).name}\t{classify(r)}\t{r}")
It is deliberately simple: it reads only the rule files a library declares in Gradle, not the rules inside the Maven artifacts those libraries depend on (the Firebase SDK, Glide, Media3 and so on ship their own). Two .pro files inside ReactAndroid’s Java sources are not named in its Gradle build, so they are not counted.
The results
Across the 14 libraries that ship consumer rules we found 119 rules: 61 member-level, 19 class-wide, 15 package-wide, 8 names only, 2 conditional, 1 global and 13 others (all -dontwarn).

Real output of the audit script over the 35 unpacked packages.
| Library | Broad rules it ships |
|---|---|
| react-native 0.88.1 | bridge, turbomodule.core (twice) and com.facebook.jni packages; every NativeModule and JavaScriptModule class kept whole |
| react-native-reanimated 4.7.2 | its own package, plus React Native’s fabric and turbomodule packages |
| react-native-worklets 0.13.1 | its own package, plus React Native’s fabric and turbomodule packages |
| expo-modules-core 58.1.0 | two package-wide rules for the v2 runtime; the rest are member-level or conditional |
| expo-notifications 58.1.9 | its whole package, nothing else |
| react-native-svg 15.16.1 | its whole public package, nothing else |
| react-native-fast-image 10.11.0 | its whole package; the Glide rules are member-level |
| @notifee/react-native 9.1.8 | keepattributes for all annotations; React Native host classes kept whole; app-wide enum and native-method rules |
The other six (expo-camera, expo-image, Crashlytics, gesture-handler, screens, track-player) ship only narrow rules or -dontwarn lines. The remaining 21 libraries, including safe-area-context, webview, mmkv, Sentry, vision-camera, async-storage, netinfo and the other Firebase modules, declare no consumer rules file at all in their Android build.
Three patterns worth knowing
Keeping someone else’s package
Reanimated and worklets each ship the same two lines about React Native, not about themselves:
-keep class com.facebook.react.turbomodule.** { *; }
-keep class com.facebook.react.fabric.** { *; }
That is exactly what the guide’s second rule warns against: a broad rule for a dependency’s code. Because consumer rules merge into the app’s configuration, any app with Reanimated keeps every class and member in React Native’s Fabric renderer and TurboModule packages, whatever React Native’s own rules say.

The same React Native package, kept two ways: everything under fabric, or one method on one interface.
Keeping every module whole
React Native’s own file has -keep class * implements com.facebook.react.bridge.NativeModule { *; }. That is class-wide, not package-wide, but it reaches every native module in the app, including those from every library above. It explains why so many libraries need no rules of their own: React Native’s rule already covers their modules.
What good looks like
Some files in the audit already follow the guide, and they make good templates:
- react-native-gesture-handler 3.5.0 keeps one method on one interface, with a comment that it is “reached only by reflection”.
- react-native-screens 4.30.1 uses
-keepnamesonly for its Fragment subclasses, and says why: the fragment factory matches them by package-name prefix when restoring state. - @react-native-firebase/crashlytics 27.1.1 names, member by member, the SDK fields and methods it reads by reflection, and notes that a missing rule only degrades a wait, never crashes.
- expo-camera 58.0.14 keeps ML Kit’s registrar classes and only their no-argument constructor, the one R8 full mode would otherwise remove.
- expo-modules-core 58.1.0 has the only
-ifrules in the audit, scoping enum field rules to packages that contain a module.
What an app team can do now
- Print the merged configuration of a release build: add
-printconfiguration build/outputs/r8-merged.txtto your app’s ownproguard-rules.pro, build, and search the file for.** {. That shows the real list for your dependency set, including rules from Maven artifacts that this audit does not cover. - Open the same build in the R8 Configuration Analyzer to see which rules keep the most code.
- For a library whose bundled rules are too broad, Google documents how to write custom rules that replace the ones bundled. Test the release build hard if you do, because the library author chose the broad rule to stop a crash.
- File an issue or a pull request upstream with the narrower rule. The Reanimated and worklets lines about React Native’s packages are the clearest candidates in our list.
- Re-run the audit on each upgrade. Our AGP 8 to 9.5 guide covers the build changes that come with it.
Versions audited
react-native 0.88.1, react-native-screens 4.30.1, react-native-safe-area-context 5.11.1, react-native-reanimated 4.7.2, react-native-worklets 0.13.1, react-native-gesture-handler 3.5.0, react-native-svg 15.16.1, react-native-webview 17.1.0, react-native-mmkv 4.3.2, @react-native-firebase/app, messaging, analytics and crashlytics 27.1.1, react-native-keychain 11.0.0, react-native-biometrics 3.0.1, react-native-share 12.3.1, react-native-track-player 4.1.2, @shopify/flash-list 2.3.3, @sentry/react-native 8.36.0, expo-modules-core 58.1.0, expo-camera 58.0.14, expo-notifications 58.1.9, expo-image 58.0.18, react-native-vision-camera 5.2.4, @react-native-async-storage/async-storage 3.1.1, react-native-device-info 15.0.2, @react-native-community/netinfo 12.0.1, lottie-react-native 7.5.1, react-native-maps 1.29.11, react-native-video 6.19.3, @react-native-google-signin/google-signin 17.0.0, react-native-permissions 5.6.3, react-native-image-picker 8.3.0, @notifee/react-native 9.1.8, react-native-fast-image 10.11.0. All packed from npm on 18 Nov 2026.



