[英]Printer method calls for a POS app behave differently for release and debug environment
I've been stuck with the problem for almost a week now. 我一直困扰这个问题近一个星期了。 The issue that I am facing is that when I set the application in debug mode, the printer functions work well;
我面临的问题是,当我将应用程序设置为调试模式时,打印机功能运行良好。 they return the correct responses and the sample texts are printed from the thermal printer the POS has.
它们返回正确的响应,并且示例文本是从POS具有的热敏打印机打印的。
However, when I switch the app to release mode, things start to behave a little differently. 但是,当我将应用程序切换到发布模式时,事情开始会有所不同。 To give you a picture of what is happening, here is the correct method calls and responses.
为了让您对正在发生的事情有一个了解,这里是正确的方法调用和响应。 You can see that the request that goes to the OS is correct and the return values are correct too.
您可以看到发送到OS的请求是正确的,返回值也正确。
09-06 21:22:04.058 357-357/? D/LibPrinterService: PrinterService getStatus...
09-06 21:22:04.072 357-357/? D/LibPrinterService: PrinterService getStatus,status=0
09-06 21:22:04.072 6412-6432/com.company.newpos D/PAYSDK: [+] Print Status: 0
09-06 21:22:04.072 357-466/? D/LibPrinterService: PrinterService getMaxTemperature...
09-06 21:22:04.074 357-466/? D/LibPrinterService: PrinterService getMaxTemperature,max=70
09-06 21:22:04.074 6412-6432/com.company.newpos D/PAYSDK: [+] Print MaxTemp: 70
09-06 21:22:04.074 357-5733/? D/LibPrinterService: PrinterService getWidth...
09-06 21:22:04.076 6412-6432/com.company.newpos D/PAYSDK: [+] Print Width: 384
09-06 21:22:04.077 357-357/? D/LibPrinterService: PrinterService getTemperature...
09-06 21:22:04.082 6412-6432/com.company.newpos D/PAYSDK: [+] Print Temp: 32
That is the correct way it should work. 那是它应该工作的正确方式。 Now when I switch to release mode.
现在,当我切换到释放模式时。 the methods behave way different.
方法的行为方式不同。 The
getStatus()
method makes the PrinterService return the current temperature ( getTemperature()
), getMaxTemperature()
returns the status ( getStatus()
). getStatus()
方法使PrinterService返回当前温度( getTemperature()
), getMaxTemperature()
返回状态( getStatus()
)。 As the result, the printer module is all messed up and the printer doesn't work. 结果,打印机模块都被弄乱了,打印机无法工作。
At first, I thought it was a proguard mapping issue (It may still be) but, the same happens even when proguard and minify are disabled. 起初,我认为这是一个proguard映射问题(可能仍然存在),但是即使禁用proguard和minify也是如此。
Can anyone help guide me or give me an idea of what might be happening here? 谁能帮助我或让我对这里可能发生的事情有所了解?
Thanks 谢谢
Try to add some delay in the connection. 尝试增加一些连接延迟。
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// put your function here.
}
}, 2000);
I later was able to solve this. 我后来能够解决这个问题。 Turn out the proguard configuration was not excluding some of the classes.
事实证明,proguard配置并未排除某些类。
So next time your app behaves radically different between release and debug mode, check your proguard configuration first. 因此,下次您的应用在发行模式和调试模式之间的行为完全不同时,请首先检查您的proguard配置。
Thank you 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.