thiendangit / react-native-thermal-receipt-printer-image-qr

React native thermal receipt printer
https://www.npmjs.com/package/react-native-thermal-receipt-printer-image-qr
119 stars 80 forks source link

Crash when trying to print in serial printer #88

Open jankoJelic opened 1 year ago

jankoJelic commented 1 year ago

Hello, I have reasons to believe this issue is specific for serial printers, because the same code has been working perfectly for all other printers up until now.

Steps to reproduce:

  1. I import USBPrinter and run init() method
  2. I successfully find devices with getDeviceList method
  3. I successfully connect to printer and confirm the access in the Android alert modal
  4. I run any printing method (printBill, printText, printRaw...)
  5. App crashes with this java error: Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hardware.usb.UsbDeviceConnection.bulkTransfer(android.hardware.usb.UsbEndpoint, byte[], int, int)' on a null object reference at com.pinmi.react.printer.adapter.USBPrinterAdapter$2.run(USBPrinterAdapter.java:235) at java.lang.Thread.run(Thread.java:919)

I have been stuck at this one for a while now, do you have any tips this type of error?