Skip to content

Commit d8bd581

Browse files
fix: ensure SoLoader library is loaded in debug mode
1 parent 1fb1665 commit d8bd581

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

.changeset/warm-tips-marry.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@callstack/repack": patch
3+
---
4+
5+
fix(android): load inspector libraries on initialization
6+
7+
Fixes `UnsatisfiedLinkError` on React Native 0.80 and above by loading inspector libraries when `ScriptManagerModule` is initialized.

packages/repack/android/src/main/java/com/callstack/repack/ScriptManagerModule.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ package com.callstack.repack
22

33
import android.os.Handler
44
import com.facebook.react.bridge.*
5+
import com.facebook.soloader.SoLoader
56

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

12+
init {
13+
ensureInspectorLoaded()
14+
}
1115
override fun getName(): String {
1216
return NAME
1317
}
@@ -106,6 +110,17 @@ class ScriptManagerModule(reactContext: ReactApplicationContext) : ScriptManager
106110
}
107111

108112
companion object {
113+
@Volatile
114+
private var inspectorLoaded = false
115+
116+
@Synchronized
117+
private fun ensureInspectorLoaded() {
118+
if (BuildConfig.DEBUG && !inspectorLoaded) {
119+
SoLoader.loadLibrary("reactnativejni")
120+
inspectorLoaded = true
121+
}
122+
}
123+
109124
init {
110125
System.loadLibrary("callstack-repack")
111126
}

0 commit comments

Comments
 (0)