Skip to content

Android: fix launch crash under R8 optimization - #71

Merged
arosasg merged 1 commit into
mainfrom
botinc/run-e75a5aa7
Nov 7, 2026
Merged

arosasg merged 1 commit into
mainfrom
botinc/run-e75a5aa7

Conversation

@botinc-agent

@botinc-agent botinc-agent Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Android apps built with R8 and proguard-android-optimize.txt crash on every launch. SdkReactNativePackage.getReactModuleInfoProvider() picked a ReactModuleInfo constructor by parameter count (7, else .first { size == 6 }). R8 removes unused constructor parameters, so neither count matched and .first threw NoSuchElementException while React Native built its module registry. The package shipped no consumer R8 rules, and CI built only a debug example. DiditAuthPackage had the same lookup.

Solution

  • Both packages call the 6-parameter ReactModuleInfo constructor directly. It is the primary, non-deprecated constructor on every React Native release from 0.76 to 0.86; the 7-parameter one is the deprecated extra. A future React Native without it would fail the host build, not the app.
  • New android/consumer-rules.pro, wired with consumerProguardFiles, keeps ReactModuleInfo's public constructors in every host app. Neither package uses other reflection.
  • The example's release build now runs R8 with proguard-android-optimize.txt. A new CI job builds it, checks the keep rule reached R8, launches it on an emulator and starts a verification, failing on any crash.

Verification

  • yarn lint, yarn typecheck and the new android-r8-consumer-rules.test.ts (3 tests) pass. An npm pack archive contains package/android/consumer-rules.pro.
  • CI run 42347523175 on 13cc015: all six jobs pass. The minified release launches, and an offline verification returns a failed result without crashing.
  • Not verified: the SDK's own screens, which need a live session token.

Refs #61

Visual proof

Screenshots from the CI job "Minified Android release launches" on an emulator. The example app was built as a release with R8 and proguard-android-optimize.txt.

The app launches without crashing:

Minified release launched

Starting a verification with a dummy token while offline reaches the native module, which returns a failed result instead of crashing. The SDK's own screens need a real session, so they are not shown here.

Verification call returned

@botinc-agent botinc-agent Bot changed the title DID-10135: [FIX-RN-R8] Android: no launch crash under R8 optimization (ReactModuleInfo looked up by reflection) Android: fix launch crash under R8 optimization Nov 7, 2026
@arosasg
arosasg merged commit 416a0f6 into main Nov 7, 2026
6 checks passed
@arosasg
arosasg deleted the botinc/run-e75a5aa7 branch November 7, 2026 10:05
@arosasg arosasg mentioned this pull request Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant