GitHub Issue Report: react-native-ble-peripheral
1. Deprecated compile dependency mapping blocks Android builds (Gradle 8+)
2. Missing DeviceEventManagerModule.RCTDeviceEventEmitter in RNBLEModule.java prevents onWrite events from ever reaching Javascript.
Description
Hello! I have been building a peer-to-peer data tool using this library to host a BLE peripheral dynamically, and I encountered two severe blocking issues natively on Android that break both the execution build step and the actual data pipeline.
Issue 1: Gradle Build Failure
In android/build.gradle, the dependencies block uses the deprecated compile command. In modern Gradle implementations (Gradle 8+, React Native 0.70+), compile has been completely removed in favor of implementation. This causes modern React Native applications traversing Expo or standard EAS pipelines to completely fail during module initialization.
Issue 2: The onWrite payload is never emitted to Javascript
In the Android native module (RNBLEModule.java), onCharacteristicWriteRequest successfully catches the incoming data payloads and packages them into a WritableMap. However, the module completely forgets to actually emit the event back to the Javascript context via DeviceEventManagerModule. The map is constructed and completely dropped into the void, making it impossible to establish bidirectional communication for the Host natively without mocking the layer. Furthermore, the required addListener and removeListeners methods are missing, violating React Native's NativeEventEmitter validation bounds.
Environment
- OS: Android (API 34)
- Library Version:
react-native-ble-peripheral@2.0.1
- React Native:
0.76.x (Expo SDK 52)
Proposed Fix (My local patch)
To get my local application compiling and receiving Host data successfully, I implemented the following patch mapping:
1. android/build.gradle (Replacing compile with implementation)
dependencies {
- compile fileTree(dir: "libs", include: ["*.jar"])
- compile "com.android.support:appcompat-v7:23.0.1"
- compile "com.facebook.react:react-native:+" // From node_modules
+ implementation fileTree(dir: "libs", include: ["*.jar"])
+ implementation "com.facebook.react:react-native:+" // From node_modules
}
2. RNBLEModule.java (Adding standard RN Device Event Emissions)
+import com.facebook.react.modules.core.DeviceEventManagerModule;
@Override
public void onCharacteristicWriteRequest(BluetoothDevice device, int requestId,
BluetoothGattCharacteristic characteristic, boolean preparedWrite, boolean responseNeeded,
int offset, byte[] value) {
super.onCharacteristicWriteRequest(device, requestId, characteristic, preparedWrite,
responseNeeded, offset, value);
characteristic.setValue(value);
WritableMap map = Arguments.createMap();
WritableArray data = Arguments.createArray();
for (byte b : value) {
data.pushInt((int) b);
}
map.putArray("data", data);
map.putString("device", device.toString());
+
+ if (reactContext != null) {
+ reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
+ .emit("onWrite", map);
+ }
+
if (responseNeeded) {
mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, value);
}
}
};
+ @ReactMethod
+ public void addListener(String eventName) { }
+
+ @ReactMethod
+ public void removeListeners(Integer count) { }
Adding these directly natively maps the Event Emitter pipeline fully back over to JS, un-blocking the library for production duplex configurations.
GitHub Issue Report: react-native-ble-peripheral
1. Deprecated
compiledependency mapping blocks Android builds (Gradle 8+)2. Missing
DeviceEventManagerModule.RCTDeviceEventEmitterinRNBLEModule.javapreventsonWriteevents from ever reaching Javascript.Description
Hello! I have been building a peer-to-peer data tool using this library to host a BLE peripheral dynamically, and I encountered two severe blocking issues natively on Android that break both the execution build step and the actual data pipeline.
Issue 1: Gradle Build Failure
In
android/build.gradle, the dependencies block uses the deprecatedcompilecommand. In modern Gradle implementations (Gradle 8+, React Native 0.70+),compilehas been completely removed in favor ofimplementation. This causes modern React Native applications traversing Expo or standard EAS pipelines to completely fail during module initialization.Issue 2: The
onWritepayload is never emitted to JavascriptIn the Android native module (
RNBLEModule.java),onCharacteristicWriteRequestsuccessfully catches the incoming data payloads and packages them into aWritableMap. However, the module completely forgets to actually emit the event back to the Javascript context viaDeviceEventManagerModule. The map is constructed and completely dropped into the void, making it impossible to establish bidirectional communication for the Host natively without mocking the layer. Furthermore, the requiredaddListenerandremoveListenersmethods are missing, violating React Native's NativeEventEmitter validation bounds.Environment
react-native-ble-peripheral@2.0.10.76.x(Expo SDK 52)Proposed Fix (My local patch)
To get my local application compiling and receiving Host data successfully, I implemented the following patch mapping:
1.
android/build.gradle(Replacingcompilewithimplementation)dependencies { - compile fileTree(dir: "libs", include: ["*.jar"]) - compile "com.android.support:appcompat-v7:23.0.1" - compile "com.facebook.react:react-native:+" // From node_modules + implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation "com.facebook.react:react-native:+" // From node_modules }2.
RNBLEModule.java(Adding standard RN Device Event Emissions)Adding these directly natively maps the Event Emitter pipeline fully back over to JS, un-blocking the library for production duplex configurations.