Skip to content

Commit 569d071

Browse files
authored
fix(⬆️): Upgraded Android build to support RN 0.76 (#2694)
In RN 0.76 there are some native libraries that are no longer available that we link in RN Skia: - reactnativejni - runtimeexecutor - turbomodulejsijni - react_nativemodule_core These have all been linked into one library file: libreactnative.so build.gradle: - Added ignore/exclude to libreactnative.so CMakeLists.txt - added tests to make sure we link with the correct library (reactnative.so) on 0.76 - added 0.76 test to avoid linking with non-existing libraries Testing: Tested with old/new arch on bare RN 0.75 + RN 0.76
1 parent ddfa6eb commit 569d071

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

packages/skia/android/CMakeLists.txt

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,13 @@ endif()
155155
message("-- JSI : " ${JSI_LIB})
156156

157157
unset(REACT_LIB CACHE)
158-
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
158+
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 76)
159+
# RN 0.76 packs react_nativemodule_core into ReactAndroid::reactnative
160+
set (REACT_LIB ReactAndroid::reactnative)
161+
elseif(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
159162
# RN 0.71 distributes prebuilt binaries.
160163
set (REACT_LIB ReactAndroid::react_nativemodule_core)
161-
else()
164+
else()
162165
find_library(
163166
REACT_LIB
164167
react_nativemodule_core
@@ -183,7 +186,10 @@ endif()
183186
message("-- FBJNI : " ${FBJNI_LIBRARY})
184187

185188
unset(REACTNATIVEJNI_LIB CACHE)
186-
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
189+
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 76)
190+
# RN 0.76 doesn't have reactnativejni
191+
# DO NOTHING, we'll not link these libraries
192+
elseif(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
187193
# RN 0.71 distributes prebuilt binaries.
188194
set (REACTNATIVEJNI_LIB "ReactAndroid::reactnativejni")
189195
else()
@@ -197,7 +203,10 @@ endif()
197203
message("-- REACTNATIVEJNI : " ${REACTNATIVEJNI_LIB})
198204

199205
unset(RUNTIMEEXECUTOR_LIB CACHE)
200-
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
206+
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 76)
207+
# RN 0.76 doesn't have runtimeexecutor
208+
# DO NOTHING, we'll not link these libraries
209+
elseif(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
201210
# RN 0.71 distributes prebuilt binaries.
202211
set (RUNTIMEEXECUTOR_LIB "ReactAndroid::runtimeexecutor")
203212
else()
@@ -211,7 +220,10 @@ endif()
211220
message("-- RUNTIMEEXECUTOR : " ${RUNTIMEEXECUTOR_LIB})
212221

213222
unset(TURBOMODULES_LIB CACHE)
214-
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
223+
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 76)
224+
# RN 0.76 doesn't have turbomodulejsijni
225+
# DO NOTHING, we'll not link these libraries
226+
elseif(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
215227
# RN 0.71 distributes prebuilt binaries.
216228
set (TURBOMODULES_LIB "ReactAndroid::turbomodulejsijni")
217229
else()
@@ -227,7 +239,26 @@ message("-- TURBO : " ${TURBOMODULES_LIB})
227239
add_definitions(-DREACT_NATIVE_VERSION=${REACT_NATIVE_VERSION})
228240

229241
# Link
230-
target_link_libraries(
242+
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 76)
243+
target_link_libraries(
244+
${PACKAGE_NAME}
245+
${LOG_LIB}
246+
${REACT_LIB}
247+
${FBJNI_LIBRARY}
248+
${JSI_LIB}
249+
${SKIA_SVG_LIB}
250+
${SKIA_SKSHAPER_LIB}
251+
${SKIA_SKPARAGRAPH_LIB}
252+
${SKIA_SKUNICODE_CORE_LIB}
253+
${SKIA_SKUNICODE_ICU_LIB}
254+
${SKIA_LIB}
255+
-ljnigraphics
256+
-lGLESv2
257+
-lEGL
258+
-landroid
259+
)
260+
else()
261+
target_link_libraries(
231262
${PACKAGE_NAME}
232263
${LOG_LIB}
233264
${FBJNI_LIBRARY}
@@ -247,3 +278,4 @@ target_link_libraries(
247278
-lEGL
248279
-landroid
249280
)
281+
endif()

packages/skia/android/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ android {
201201
"**/libreactnativejni.so",
202202
"**/libruntimeexecutor.so",
203203
"**/libturbomodulejsijni.so",
204+
"**/libreactnative.so",
204205
"META-INF/**"
205206
]
206207
}

0 commit comments

Comments
 (0)