feat(react-native): add Android support for controller native module#34
Merged
feat(react-native): add Android support for controller native module#34
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
build_android.shscript for cross-compiling Rust to AndroidChanges
New Android Module Files
modules/controller/android/build.gradle- Android library configurationmodules/controller/android/CMakeLists.txt- CMake build for NDKmodules/controller/android/cpp-adapter.cpp- JNI bridge to C++ FFImodules/controller/android/src/main/java/.../ControllerModule.kt- TurboModule implementationmodules/controller/android/src/main/java/.../ControllerPackage.kt- React Native packagemodules/controller/android/src/main/jniLibs/*/libcontroller_uniffi.so- Pre-built native libsUpdated Files
react-native.config.js- Added Android platform configurationREADME.md- Cross-platform documentation and quick start guidescripts/build_android.sh- Build script for Android native libsTest Plan
./gradlew assembleDebug)Prerequisites for Rebuilding Android Libs