Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/strong-cycles-spark.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@use-voltra/android-client': patch
---

Fix Android builds for React Native 0.81 apps by linking the correct Hermes prefab target.
26 changes: 23 additions & 3 deletions packages/android-client/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,25 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
# We consume them through find_package below.
#
# NOTE: find_package does NOT error on a wrong target *name* — the failure only
# surfaces at target_link_libraries. The correct Hermes prefab target on Android
# (RN 0.83, com.facebook.react:hermes-android) is `hermes-engine::hermesvm`.
# surfaces at target_link_libraries. The Hermes prefab target on Android has
# been renamed across RN versions (com.facebook.react:hermes-android):
# - RN <= 0.81: prefab module `libhermes` -> CMake target hermes-engine::libhermes
# - RN >= 0.82: prefab module `hermesvm` -> CMake target hermes-engine::hermesvm
# We branch on which target find_package actually resolved so Voltra builds
# against both RN generations, and fail fast at configure time if neither
# exists (e.g. a future prefab rename) instead of erroring later at link time.
find_package(ReactAndroid REQUIRED CONFIG)
find_package(hermes-engine REQUIRED CONFIG)
find_package(fbjni REQUIRED CONFIG)

if(TARGET hermes-engine::hermesvm)
set(VOLTRA_HERMES_TARGET hermes-engine::hermesvm) # RN >= 0.82
elseif(TARGET hermes-engine::libhermes)
set(VOLTRA_HERMES_TARGET hermes-engine::libhermes) # RN <= 0.81
else()
message(FATAL_ERROR "Voltra: hermes-engine prefab found but neither target hermes-engine::hermesvm (RN >= 0.82) nor hermes-engine::libhermes (RN <= 0.81) exists. Unsupported React Native version?")
endif()

# ---------------------------------------------------------------------------
# Voltra JS Renderer (Dynamic Widgets on Android)
# ---------------------------------------------------------------------------
Expand All @@ -28,6 +41,13 @@ target_link_libraries(voltra_js_renderer
android
log
ReactAndroid::jsi
hermes-engine::hermesvm
${VOLTRA_HERMES_TARGET}
fbjni::fbjni
)

# 16KB page size support: explicitly align libvoltra_js_renderer.so to 16KB
# pages regardless of host NDK version. NDK r28+ defaults to this, but we
# pin it explicitly so older NDKs also produce 16KB-compatible output. We
# only support 16KB alignment (no 4KB-only build) — 16KB-aligned libs run
# fine on 4KB-page devices too.
target_link_options(voltra_js_renderer PRIVATE "-Wl,-z,max-page-size=16384")
12 changes: 7 additions & 5 deletions packages/android-client/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ android {
buildFeatures {
buildConfig true
compose true
// Required to consume React Native's published prefab modules (jsi, hermesvm, fbjni).
// Required to consume React Native's published prefab modules (jsi, hermes, fbjni).
prefab true
}

Expand All @@ -71,6 +71,7 @@ android {
"**/libfbjni.so",
"**/libjsi.so",
"**/libhermes.so",
"**/libhermesvm.so",
]
}

Expand All @@ -95,10 +96,11 @@ android {
dependencies {
// React Native
implementation "com.facebook.react:react-android"
// Provides the `hermes-engine` prefab (libhermesvm) that CMakeLists.txt's
// find_package(hermes-engine) consumes for the standalone Hermes JS runtime. Without it the
// native build fails to configure in release variants (react-android alone does not publish the
// Hermes prefab). Version is substituted by the React Native Gradle Plugin (applied above).
// Provides the `hermes-engine` prefab (libhermes on RN <= 0.81, libhermesvm on RN >= 0.82)
// that CMakeLists.txt's find_package(hermes-engine) consumes for the standalone Hermes JS
// runtime. Without it the native build fails to configure in release variants (react-android
// alone does not publish the Hermes prefab). Version is substituted by the React Native
// Gradle Plugin (applied above).
implementation "com.facebook.react:hermes-android"

// Jetpack Glance
Expand Down
Loading