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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/warm-tips-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@callstack/repack": patch
---

fix(android): load inspector libraries on initialization

Fixes `UnsatisfiedLinkError` on React Native 0.80 and above by loading inspector libraries when `ScriptManagerModule` is initialized.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ package com.callstack.repack

import android.os.Handler
import com.facebook.react.bridge.*
import com.facebook.soloader.SoLoader

class ScriptManagerModule(reactContext: ReactApplicationContext) : ScriptManagerSpec(reactContext) {
private val nativeLoader = NativeScriptLoader(reactApplicationContext)
private val remoteLoader = RemoteScriptLoader(reactApplicationContext, nativeLoader)
private val fileSystemLoader = FileSystemScriptLoader(reactApplicationContext, nativeLoader)

init {
ensureInspectorLoaded()
}
override fun getName(): String {
return NAME
}
Expand Down Expand Up @@ -106,6 +110,17 @@ class ScriptManagerModule(reactContext: ReactApplicationContext) : ScriptManager
}

companion object {
@Volatile
private var inspectorLoaded = false

@Synchronized
private fun ensureInspectorLoaded() {
if (BuildConfig.DEBUG && !inspectorLoaded) {
SoLoader.loadLibrary("reactnativejni")
inspectorLoaded = true
}
}

init {
System.loadLibrary("callstack-repack")
}
Expand Down