Skip to content

Commit 4f9f24e

Browse files
cortinicometa-codesync[bot]
authored andcommitted
Use legacy JNI packaging for ARM64 Android E2E APKs (#58103)
Summary: Follow-up to #58092. Android API 35 x86_64 emulator images expose both `x86_64` and `arm64-v8a` through `libndk_translation.so`. SoLoader 0.12.1 only searches the first ABI when loading uncompressed native libraries directly from the APK, causing ARM64-only RNTester and template apps to crash while loading `libreactnative.so`. Enable legacy JNI packaging through a CI-only Gradle init script so Android extracts the ARM64 libraries and the existing SoLoader `ApplicationSoSource` can load them. This applies only to dry-run RNTester builds and Android template E2E builds. Nightly and release packaging is unchanged. Failure evidence: https://github.com/react/react-native/actions/runs/32741094253 ## Changelog: [INTERNAL] [FIXED] - Extract native libraries for ARM64 Android E2E APKs running through NDK translation. Pull Request resolved: #58103 Test Plan: - `./node_modules/.bin/prettier --check .github/actions/build-android/action.yml .github/workflows/e2e-android-templateapp.yml` — passed. - Parsed both modified YAML files with the `yaml` Node package — passed. - Parsed the embedded workflow shell scripts with `bash -n` — passed. - Compiled `.github/workflow-scripts/legacy-jni-packaging.gradle` with the Groovy compiler bundled with Gradle 9.4.1 — passed. - Full Android E2E validation is delegated to this draft PR because the local Gradle daemon could not establish its localhost connection. Reviewed By: christophpurrer Differential Revision: D117222109 Pulled By: cortinico fbshipit-source-id: 65e09a38eed84474a2f50f7f5847e1676da4411b
1 parent ab2ea64 commit 4f9f24e

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

.github/actions/build-android/action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,17 @@ runs:
5151
- name: Build and publish all the Android Artifacts to /tmp/maven-local
5252
shell: bash
5353
run: |
54+
GRADLE_ARGS=()
5455
if [[ "${{ inputs.release-type }}" == "dry-run" ]]; then
5556
# dry-run: we only build ARM64 to save time/resources. Android E2E
5657
# runs this APK on an x86_64 API 35 image using NDK translation.
5758
# For release/nightlies the default is to build all architectures.
5859
export ORG_GRADLE_PROJECT_reactNativeArchitectures="arm64-v8a"
5960
export HERMES_PREBUILT_FLAG="ORG_GRADLE_PROJECT_react.internal.useHermesNightly=true"
61+
GRADLE_ARGS=(
62+
--init-script
63+
"$GITHUB_WORKSPACE/.github/workflow-scripts/legacy-jni-packaging.gradle"
64+
)
6065
TASKS="publishAllToMavenTempLocal build"
6166
elif [[ "${{ inputs.release-type }}" == "nightly" ]]; then
6267
# nightly: we set isSnapshot to true so artifacts are sent to the right repository on Maven Central.
@@ -69,7 +74,7 @@ runs:
6974
export HERMES_PREBUILT_FLAG="ORG_GRADLE_PROJECT_react.internal.useHermesStable=true"
7075
TASKS="publishAllToMavenTempLocal publishAndroidToSonatype closeSonatypeStagingRepository build"
7176
fi
72-
env "$HERMES_PREBUILT_FLAG" ./gradlew $TASKS -PenableWarningsAsErrors=true
77+
env "$HERMES_PREBUILT_FLAG" ./gradlew "${GRADLE_ARGS[@]}" $TASKS -PenableWarningsAsErrors=true
7378
- name: Save Android ccache
7479
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }}
7580
uses: actions/cache/save@v5
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
// Extract native libraries when installing ARM64-only APKs on x86_64 emulators. This lets Android's
9+
// native bridge select the translated ABI without relying on SoLoader's direct-from-APK ABI lookup.
10+
allprojects { project ->
11+
project.pluginManager.withPlugin("com.android.application") {
12+
project.extensions.getByName("android").packaging.jniLibs.useLegacyPackaging = true
13+
}
14+
}

.github/workflows/e2e-android-templateapp.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ jobs:
7474
# Build
7575
cd android
7676
CAPITALIZED_FLAVOR=$(echo "${{ matrix.flavor }}" | awk '{print toupper(substr($0, 1, 1)) substr($0, 2)}')
77-
./gradlew assemble$CAPITALIZED_FLAVOR --no-daemon -PreactNativeArchitectures=arm64-v8a
77+
./gradlew --no-daemon \
78+
--init-script "$GITHUB_WORKSPACE/.github/workflow-scripts/legacy-jni-packaging.gradle" \
79+
assemble$CAPITALIZED_FLAVOR \
80+
-PreactNativeArchitectures=arm64-v8a
7881
7982
- name: Download previous per-flow test state
8083
if: ${{ inputs.retry-attempt > 0 }}

0 commit comments

Comments
 (0)