2

I use RN version: "0.61.5"

The problem is that I installed react-native-beacons-manager 1.0.7 (note that the npm version the last time was updated a long time ago, but I tried the last Github version as well) but I can't use it as when I try to run my application the app crashes. Moreover, it doesn't show the red screen with an error stack trace. I looked into logs and found out that the problem is connected with WrittableArray, here's logs

2020-05-05 06:20:49.500 5218-5306/com.freeline E/AndroidRuntime: FATAL EXCEPTION: IntentService[BeaconIntentProcessor]
    Process: com.freeline, PID: 5218
    java.lang.NoSuchMethodError: No interface method putArray(Ljava/lang/String;Lcom/facebook/react/bridge/WritableArray;)V in class Lcom/facebook/react/bridge/WritableMap; or its super classes (declaration of 'com.facebook.react.bridge.WritableMap' appears in /data/app/com.freeline-BgN5GbjFCm9weblBl35oBw==/base.apk)
        at com.mackentoch.beaconsandroid.BeaconsAndroidModule.createRangingResponse(BeaconsAndroidModule.java:299)
        at com.mackentoch.beaconsandroid.BeaconsAndroidModule.access$300(BeaconsAndroidModule.java:37)
        at com.mackentoch.beaconsandroid.BeaconsAndroidModule$2.didRangeBeaconsInRegion(BeaconsAndroidModule.java:280)
        at org.altbeacon.beacon.BeaconIntentProcessor.onHandleIntent(BeaconIntentProcessor.java:68)
        at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:76)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:201)
        at android.os.HandlerThread.run(HandlerThread.java:65)

I found the function that caused the crashes, here it is:

    private WritableMap createRangingResponse(Collection<Beacon> beacons, Region region) {
        WritableMap map = new WritableNativeMap();
        map.putString("identifier", region.getUniqueId());
        map.putString("uuid", region.getId1() != null ? region.getId1().toString() : "");
        WritableArray a = new WritableNativeArray();
        for (Beacon beacon : beacons) {
            WritableMap b = new WritableNativeMap();
            b.putString("uuid", beacon.getId1().toString());
            b.putInt("major", beacon.getId2().toInt());
            b.putInt("minor", beacon.getId3().toInt());
            b.putInt("rssi", beacon.getRssi());
            b.putDouble("distance", beacon.getDistance());
            b.putString("proximity", getProximity(beacon.getDistance()));
            a.pushMap(b);
        }
        map.putArray("beacons", a); // <- The line that produces the exception
        return map;
    }

Then I read a bunch of posts and understand that the problem is in the implementation of WritableMap in new versions of RN.

So, my question is: Is there any method to resolve it, I've already addressed the issue here. I'm aware of the possibility of downgrading the RN version to ^60, but I'd keep it as the last possible method.

Appreciate your help

1 Answer 1

1

I solved the problem simply by downgrading to the version 60.6 of RN.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.