HeligPfleigh / react-native-thermal-receipt-printer

A RN library for thermal printer
155 stars 102 forks source link

NullObject Reference #134

Open sejeeth11 opened 1 year ago

sejeeth11 commented 1 year ago

"Attempt to invoke interface method 'java.util.List com.pinmi.react.printer.adapter.PrinterAdapter.getDeviceList(com.facebook.react.bridge.Callback)' on a null object reference"

PeterOzbot commented 1 year ago

I had the same issue and solved it by fixing the example code. BLEPrinter example should use BLEPrinter.print.. and not USBPrinter.print...

In this two methods replace USBPrinter with BLEPrinter.

  printTextTest = () => {
    currentPrinter && USBPrinter.printText("<C>sample text</C>\n");
  }

  printBillTest = () => {
    currentPrinter && USBPrinter.printBill("<C>sample bill</C>");
  }

Anyway this is how I solved this issue. Maybe it will help someone.