question

marc-omorain avatar image
marc-omorain asked dansl edited

NullPointerException caused by StaticBillPrintJob

Hi there,

I'm having more problems trying to make Clover print orders, following on from https://devask.clover.com/question/31...

My code is starting a new print job, which causes an NPE on the print thread which is not part of my app (com.clover.engine.services). This means that I cannot catch the exception. When the NullPointerException occurs the Clover Mini device will play the error noise over and over until someone manually clears the print queue (!). I can't ship app where trying to print an order causes the POS to malfunction like this, so I'd really appreciate any help debugging this.

The NPE has the following stack trace:

08-10 16:02:55.065 1727-23209/? W/SeikoMini: onHandleIntent(PrinterIntentService.java:391): print failed, printer: Printer{uuid=AHPNN7RZVWDVP, type=SEIKO_MINI_USB, name=Mini, mac=null, ip=null, category=RECEIPT}
java.lang.NullPointerException
at com.clover.engine.services.ReceiptPrinterPlugins.ReceiptGenerator.createReceiptView(ReceiptGenerator.java:1711)
at com.clover.engine.services.ReceiptPrinterPlugins.ReceiptGenerator.createReceiptView(ReceiptGenerator.java:1576)
at com.clover.engine.services.ReceiptPrinterPlugins.seiko.SeikoMini.printReceipt(SeikoMini.java:75)
at com.clover.engine.services.PrinterIntentService.onHandleIntent(PrinterIntentService.java:320)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.os.HandlerThread.run(HandlerThread.java:61)

My (Kotlin) code is here: https://gist.github.com/marcomorain/f...

The problematic line is:

StaticBillPrintJob.Builder().order(o).build().print(context, account, printer)

This causes the NPE in the other activity.

Can you share the source of ReceiptGenerator.java or otherwise help me understand how avoid the NPE on line 391?

The order is created by our backend-server, and the order definitely exists before we ask the device to print it. We create the order, after which we send a notification to the device using the notifications API.

Thanks,

Marc

11 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

marc-omorain avatar image marc-omorain commented ·

Some updates as I try to work around this:

  • The (deprecated) BillPrintJob also causes the NPE.
  • The StaticOrderPrintJob prints OK, but the order format is not suitable for us.
  • The StaticReceiptPrintJobalso causes the NPE. Stack trace: https://gist.github.com/marcomorain/a...
0 Likes 0 ·
Bryanne Vega avatar image Bryanne Vega commented ·

What do you mean by the order format is not suitable? Is it missing something?

0 Likes 0 ·
marc-omorain avatar image marc-omorain commented ·

Hi Bryanne, The Order format doesn't show the prices of items, or the total. It also has very large font (for use in the kitchen I assume).

0 Likes 0 ·
marc-omorain avatar image marc-omorain commented ·

The frustrating issue here is that I can view the order in the Orders app and I can print the order no problem using any of the options available.

0 Likes 0 ·
marc-omorain avatar image marc-omorain commented ·

bump? can you offer any help with this at Clover?

0 Likes 0 ·
Show more comments

1 Answer

dansl avatar image
dansl answered dansl edited
Hey, we had this issue recently too. We found that for some reason the Order Object didn't have an "employee" assigned to it, so we just grabbed the Owners employee ID and added it to the Order Object before we tried to print it. Let me know if this helps.
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community