fix: comprehensive React Native 0.80.0+ compatibility fix #1312
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.
Problem
React Native 0.80.0 was the first release to include the PromiseImpl null-safety changes.
The React Native Commit in April 2025
"fix nullsafe FIXMEs for PromiseImpl.java and mark nullsafe"
by Gijs Weterings
4c8ea858a53 - fix nullsafe FIXMEs for PromiseImpl.java and mark nullsafe
What This Means:
React Native 0.80.0+ enforces non-null error codes in PromiseImpl.reject()
React Native 0.79.x and earlier allowed null as the error code
The change added @nullsafe(Nullsafe.Mode.LOCAL) annotation to PromiseImpl class
This triggers NullPointerException when null is passed as the error code
Root Cause
React Native 0.80.0+ added
@Nullsafe(Nullsafe.Mode.LOCAL)annotation toPromiseImplclass, which enforces non-null error codes at runtime.This bluetooth library was calling in a lot of places:
But React Native 0.80.0+ now requires:
React Native 0.80.0 was the first release to include this change that broke some features of this library
Impact
It fixes an urgent compatibility issue impacting a wide range of users forced to move to React Native 0.81.4+ (especially Expo SDK 54+ projects). Updating to Expo 54 makes it impossible to use this library without crash, since Expo 54 is only compatible with React Native 0.81.4+.
This will fix issues for Ledger reactive native Device Management SDK and other reactive native SDKs which use this library as the transport layer.
Related Issue that I reported 2 days ago: #1310 - Android crash in BLETransport APIs when React Native version is 0.81.4
Solution
Replace all
nullerror codes with properBleErrorCodeenum values usingerror.errorCode.name().Java code changes in this PR
In android/src/main/java/com/bleplx/BlePlxModule.java
safePromise.reject(null, ...)withsafePromise.reject(error.errorCode.name(), ...)promise.reject(null, ...)withpromise.reject(error.errorCode.name(), ...)promise.reject(null, ...)withpromise.reject(bleError.errorCode.name(), ...)Testing results
Error Log
Some more details of Native Android logs here: