From caf6bd506f30d4e758b1756cbd368fd1c1b79175 Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Fri, 30 Oct 2026 23:17:33 +0100 Subject: [PATCH 1/2] Keep ActivityResultContract class names in R8 builds Co-Authored-By: Claude Opus 5.5 --- packages/react-native/ReactAndroid/proguard-rules.pro | 4 ++++ .../com/facebook/react/activityresult/__docs__/README.md | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/proguard-rules.pro b/packages/react-native/ReactAndroid/proguard-rules.pro index 7e6c92af074a..0db726d9a2af 100644 --- a/packages/react-native/ReactAndroid/proguard-rules.pro +++ b/packages/react-native/ReactAndroid/proguard-rules.pro @@ -73,3 +73,7 @@ -keep public class com.facebook.imageutils.** { public *; } + +# Activity result launcher keys include the contract's class name. Keep those names so that R8 +# doesn't merge different contracts into one class or rename them between builds. +-keepnames class * extends androidx.activity.result.contract.ActivityResultContract diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/activityresult/__docs__/README.md b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/activityresult/__docs__/README.md index bdc6c9bdf046..991f840f9320 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/activityresult/__docs__/README.md +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/activityresult/__docs__/README.md @@ -61,7 +61,10 @@ The same stability concern applies to minification. If the app minifies class names (R8/ProGuard), the obfuscated name of the owner class is not guaranteed to be the same from one build to the next, so a result delivered after an app update can be dropped. Keep the owner class's name (for example with -`-keepnames`) if results must survive across builds. +`-keepnames`) if results must survive across builds. React Native's consumer +R8 rules already keep the names of `ActivityResultContract` subclasses, so R8 +doesn't merge different contracts into one class, which would give them the +same key. Registering the same contract class twice from one owner throws `IllegalStateException`. In that case use the overload that takes a key: From 2bf04cbdb9e693eee0fc70332b400e9d15fb9c54 Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Sat, 31 Oct 2026 10:22:25 +0100 Subject: [PATCH 2/2] Format the activity result README Co-Authored-By: Claude Opus 5.5 --- .../com/facebook/react/activityresult/__docs__/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/activityresult/__docs__/README.md b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/activityresult/__docs__/README.md index 991f840f9320..1542339a6071 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/activityresult/__docs__/README.md +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/activityresult/__docs__/README.md @@ -61,10 +61,10 @@ The same stability concern applies to minification. If the app minifies class names (R8/ProGuard), the obfuscated name of the owner class is not guaranteed to be the same from one build to the next, so a result delivered after an app update can be dropped. Keep the owner class's name (for example with -`-keepnames`) if results must survive across builds. React Native's consumer -R8 rules already keep the names of `ActivityResultContract` subclasses, so R8 -doesn't merge different contracts into one class, which would give them the -same key. +`-keepnames`) if results must survive across builds. React Native's consumer R8 +rules already keep the names of `ActivityResultContract` subclasses, so R8 +doesn't merge different contracts into one class, which would give them the same +key. Registering the same contract class twice from one owner throws `IllegalStateException`. In that case use the overload that takes a key: