Skip to content

[FIX] fix(android): load inspector libraries on initialization #1213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

raghav-reglobe
Copy link
Contributor

🔧 Fix Android UnsatisfiedLinkError for DevTools on RN 0.80+

Summary

Problem
Opening the DevTools network-inspector on Android crashes with
UnsatisfiedLinkError: ...InspectorNetworkRequestListener.onHeaders(...)
when the app is built with React Native 0.80 or later.

Root cause
RN 0.80 stopped pre-loading libreactnativejni.so, which contains the
InspectorNetworkRequestListener JNI stubs.
Re.Pack initialises its ScriptManagerModule before RN has loaded the library.

Fix
Call SoLoader.loadLibrary("reactnativejni") once during
ScriptManagerModule initialisation, guarded by BuildConfig.DEBUG so it
runs only in debug builds.

Implementation details

  • Added ensureInspectorLoaded() in ScriptManagerModule.
  • Guarded with a @Volatile flag to ensure the load happens exactly once.
  • No impact on release APKs (code path is skipped).

Test plan

Preconditions

  • Android device/emulator.
  • App built with RN 0.80+ and this patch applied.

Steps

  1. Launch the app.
  2. Open the dev menu (⌘ M / Ctrl M or shake).
  3. Press j in the terminal to open the JS debugger.

Expected

  • App remains running.
  • A Chrome tab opens and successfully attaches to the JS runtime.

Before this fix

  • The app crashed immediately with the UnsatisfiedLinkError.

Changelog

  • Android: Fix crash when opening DevTools on RN 0.80 + by lazily loading libreactnativejni.so.

Checklist

  • Ran on a physical device
  • Verified debug build still strips inspector code in release
  • Added a unit test (N/A – runtime linker issue)

Copy link

vercel bot commented Jul 7, 2025

@raghav-reglobe is attempting to deploy a commit to the Callstack Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Jul 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
repack-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 7, 2025 7:18pm

Copy link

changeset-bot bot commented Jul 7, 2025

🦋 Changeset detected

Latest commit: d8bd581

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@callstack/repack Patch
@callstack/repack-plugin-expo-modules Patch
@callstack/repack-plugin-nativewind Patch
@callstack/repack-plugin-reanimated Patch
@callstack/repack-dev-server Patch
@callstack/repack-init Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jbroma
Copy link
Member

jbroma commented Jul 25, 2025

@raghav-reglobe I've reviewed the PR and our DevTools integration and found that these changes are not needed. In principle, ScriptManager module should not have any dependency / reliance on the DevTools integration, so the changes in this PR are not fixing the root cause.

I've made necessary fixes for RN 80 compatibility in #1227 and got the DevTools working for all of the testers in the monorepo.

Sorry for the delayed response, and thank you for your time & contribution nonetheless. I'll close this PR since it's not needed anymore, but please do not feel discouraged from submitting another contributions in the future!

@jbroma jbroma closed this Jul 25, 2025
@raghav-reglobe
Copy link
Contributor Author

Thanks

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.

2 participants