Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary:
ReactActivityResultCallerkeys each launcher by"<owner class>:<contract class>". With R8 enabled, it can merge different contract classes into one class (horizontal class merging), so they end up with the same name. For example, in a minified RNTester build,ActivityResultContracts.RequestPermission,PickVisualMediaandGetContentwere all merged into a class namede2. Registering a second contract from the same owner then throwsIllegalStateException: A launcher is already registered for key '…:e2'. That's whySampleTurboModulefails to initialize in a minified RNTester.This adds a consumer R8 rule that keeps the names of
ActivityResultContractsubclasses, which stops R8 from merging or renaming them. Unused contracts can still be removed. It also keeps the keys stable between builds, which the docs ask for. The docs now mention the rule.Changelog:
[INTERNAL] [FIXED] - Keep
ActivityResultContractclass names in R8 builds so that activity result launcher keys don't collideTest Plan:
Minified release RNTester:
./gradlew :packages:rn-tester:android:app:assembleRelease -PreactNativeArchitectures=arm64-v8a, withenableProguardInReleaseBuilds = true.main:ActivityResultContracts$GetContent -> e2, a merged class with an$r8$classIdfield.ActivityResultContracts$RequestPermission -> ActivityResultContracts$RequestPermission.SampleTurboModule:main:Exception in HostObject::get for prop 'SampleTurboModule': java.lang.IllegalStateException: A launcher is already registered for key 'com.facebook.fbreact.specs.SampleTurboModule:e2'getObject,getArrayandgetConstantsreturn the expected values.🤖 Generated with Claude Code