Skip to content

Conversation

@jvsena42
Copy link
Member

@jvsena42 jvsena42 commented Nov 17, 2025

Description

Fixes Android build errors when using react-native-ldk with React Native 0.78.

Problem

The package fails to compile on RN 0.78 with errors:

  • Unresolved reference 'reactContext'
  • Unresolved reference 'runOnUiThread'

Solution

  1. Added getReactContext() getter method to LdkEventEmitter object
  2. Updated LdkPersister.kt to use LdkEventEmitter.getReactContext() instead of LdkModule.reactContext
  3. Replaced deprecated runOnUiThread() with runOnUiQueueThread()

Testing

  1. Before linking, the TypeScript source must be compiled:
cd /path/to/react-native-ldk/lib
yarn install  # This runs prepublish script which builds the dist/ folder
  1. Link the local package:
# In the consuming project's package.json
"@synonymdev/react-native-ldk": "file:/path/to/react-native-ldk/lib"

# Then install
yarn install
  1. Verify the local version is linked:
ls -la node_modules/@synonymdev/react-native-ldk/
grep "getReactContext" node_modules/@synonymdev/react-native-ldk/android/src/main/java/com/reactnativeldk/LdkModule.kt
grep "runOnUiQueueThread" node_modules/@synonymdev/react-native-ldk/android/src/main/java/com/reactnativeldk/classes/LdkPersister.kt
  1. Clean previous builds:
cd android
./gradlew clean
cd ..
  1. Build and run:
yarn start
# Open another terminal
yarn android
  • Builds successfully on Android with RN 0.78
  • App runs without crashes
  • LDK functionality works as expected

@jvsena42 jvsena42 self-assigned this Nov 17, 2025
@jvsena42
Copy link
Member Author

Worked locally, trying to fix the CI

@jvsena42 jvsena42 requested a review from Copilot November 18, 2025 12:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes Android build compatibility issues with React Native 0.78 by updating deprecated APIs and improving context access patterns in the react-native-ldk package.

Key changes:

  • Added a getter method for ReactContext in LdkEventEmitter to resolve reference errors
  • Replaced deprecated runOnUiThread() with runOnUiQueueThread() for RN 0.78 compatibility
  • Added Metro config blocklist to prevent nested dependency conflicts

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/package.json Version bump to 0.0.162
lib/android/src/main/java/com/reactnativeldk/classes/LdkPersister.kt Updated to use new context getter and RN 0.78 thread method
lib/android/src/main/java/com/reactnativeldk/LdkModule.kt Added getReactContext() getter method to LdkEventEmitter
example/tests/eclair.ts Added missing trailing comma
example/metro.config.js Added blocklist to exclude nested node_modules

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jvsena42 jvsena42 marked this pull request as ready for review November 18, 2025 12:15
@jvsena42
Copy link
Member Author

The CI failures will be fixed in other branch

Copy link
Contributor

@ovitrif ovitrif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with some nit comments for cleanup as feasible.


// Update chain monitor on main thread
LdkModule.reactContext?.runOnUiThread {
LdkEventEmitter.getReactContext()?.runOnUiQueueThread {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this change doesn't make a lot of sense to me. Why would we change what was already there?!

Copy link
Member Author

@jvsena42 jvsena42 Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ReactNative version of the project was updated


//Update chain monitor with successful persist on main thread
LdkModule.reactContext?.runOnUiThread {
LdkEventEmitter.getReactContext()?.runOnUiQueueThread {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this change doesn't make a lot of sense to me. Why would we change what was already there?!

@jvsena42 jvsena42 merged commit 1ae2063 into master Nov 18, 2025
2 of 6 checks passed
@jvsena42 jvsena42 deleted the fix/rn-0.78-compatibility branch November 18, 2025 14:43
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.

3 participants