Description

I am not so sure if this is a bug with React Native, or I am doing something wrong. I am creating a point of sale app. I have bridged a native android library to react native that allows the app to connect to a magnetic card reader peripheral, and read card details into the app from it via the device's headphone jack. There is a bug that causes the app to automatically close if the magnetic card swipe peripheral is not connected when the app is started. the error code I get back is this:

java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.HEADSET_PLUG flg=0x40000010 (has extras) } in com.imagpay.bP@35df2f9

at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:972)

at android.os.Handler.handleCallback(Handler.java:743)

at android.os.Handler.dispatchMessage(Handler.java:95)

at android.os.Looper.loop(Looper.java:150)

at android.app.ActivityThread.main(ActivityThread.java:5621)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)

Caused by: java.lang.NullPointerException: Attempt to read from field 'boolean com.imagpay.bN.i' on a null object reference

When i use the same library in a purely native android app, it works properly and does not close if the peripheral is not connected. Is there something I am missing in react native or is this a bug with react native? I have posted several times on stackoverflow and no one seems to know what to do.

Reproduction

Links to my code are here:

thats the code for the entire app. the faulty code is at:

in react native and:

is where the java module is implemented

[FILL THIS OUT: Try to reproduce your bug on rnplay.org and provide a link. If you can't reproduce the bug on rnplay.org, provide a sample project.]

Solution

????

Additional Information

React Native version: 0.39.0

Platform: Android

Operating System: MacOS X Sierra

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐