Skip to content

feat(react-native): add Android support for controller native module#34

Merged
Larkooo merged 6 commits intomainfrom
feature/react-native-android-support
Jan 15, 2026
Merged

feat(react-native): add Android support for controller native module#34
Larkooo merged 6 commits intomainfrom
feature/react-native-android-support

Conversation

@Larkooo
Copy link
Contributor

@Larkooo Larkooo commented Jan 9, 2026

Summary

  • Add full Android native module structure (Kotlin TurboModule)
  • Add CMakeLists.txt and build.gradle for NDK compilation
  • Add JNI adapter (cpp-adapter.cpp) bridging Java to Rust FFI
  • Add pre-built native libraries for all Android ABIs (arm64-v8a, armeabi-v7a, x86, x86_64)
  • Add build_android.sh script for cross-compiling Rust to Android
  • Update configurations and documentation for cross-platform support

Changes

New Android Module Files

  • modules/controller/android/build.gradle - Android library configuration
  • modules/controller/android/CMakeLists.txt - CMake build for NDK
  • modules/controller/android/cpp-adapter.cpp - JNI bridge to C++ FFI
  • modules/controller/android/src/main/java/.../ControllerModule.kt - TurboModule implementation
  • modules/controller/android/src/main/java/.../ControllerPackage.kt - React Native package
  • modules/controller/android/src/main/jniLibs/*/libcontroller_uniffi.so - Pre-built native libs

Updated Files

  • react-native.config.js - Added Android platform configuration
  • README.md - Cross-platform documentation and quick start guide
  • scripts/build_android.sh - Build script for Android native libs

Test Plan

  • Build native libraries for all Android ABIs
  • Build Android APK successfully (./gradlew assembleDebug)
  • Test on Android device/emulator
  • Verify iOS still works after changes

Prerequisites for Rebuilding Android Libs

cargo install cargo-ndk
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
./scripts/build_android.sh

This adds full Android support for the React Native controller module:

- Add Android native module structure (Kotlin TurboModule)
  - ControllerModule.kt - Main TurboModule implementation
  - ControllerPackage.kt - React Native package registration
  - NativeControllerSpec.kt - Base spec class
- Add CMakeLists.txt for NDK C++ compilation
- Add build.gradle for Android library configuration
- Add cpp-adapter.cpp for JNI bridge to Rust FFI
- Add build_android.sh script for cross-compiling Rust to Android ABIs
- Update react-native.config.js to include Android platform
- Update README with Android setup instructions

Prerequisites for building Android:
- cargo-ndk (cargo install cargo-ndk)
- Android NDK via Android Studio
- Rust Android targets (aarch64-linux-android, etc.)
Add compiled .so files for all Android ABIs:
- arm64-v8a (20MB)
- armeabi-v7a (16MB)
- x86 (20MB)
- x86_64 (19MB)

These are analogous to the iOS .a files in the xcframework.
- Update error message to be platform-agnostic
- Update README with both iOS and Android sections
- Add Quick Start section for easier onboarding
- Document project structure for both platforms
- Add Android-specific troubleshooting commands
iOS:
- Controller native module working with New Architecture
- TurboModule registers JSI bindings correctly
- Tested and confirmed working on iOS simulator

Android:
- Updated native libraries with proper SONAME for linking
- Implemented TurboReactPackage with correct ReactModuleInfo
- JNI adapter compiles and links with libcontroller_uniffi.so
- TurboModule registration still not being found by JS
- WIP: Investigating New Architecture bridgeless mode compatibility

Also:
- Added SONAME flag to build_android.sh for proper .so linking
- Updated NativeController.ts with platform-specific loading logic
…ture

- Simplify cpp-adapter.cpp to use sync CallInvoker created in C++
- Remove internal React Native API usage from ControllerModule.kt
- Switch from TurboReactPackage to standard ReactPackage
- Add fbjni dependency to CMakeLists.txt
- Remove TurboModule interface from NativeControllerSpec
- Auto-install JSI bindings during module initialization
- Simplify NativeController.ts to have single TurboModuleRegistry call (codegen requirement)
- Move platform-specific module resolution to index.tsx
- Remove duplicate js/NativeController.js spec file
- Android uses NativeModules bridge, iOS uses TurboModule
@Larkooo Larkooo merged commit b9ad2c6 into main Jan 15, 2026
@Larkooo Larkooo deleted the feature/react-native-android-support branch January 15, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments