简体   繁体   English

POS应用程序的打印机方法调用在发布和调试环境中的行为有所不同

[英]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.

相关问题 HockeyApp启动我的应用程序,并使其行为有所不同。 是什么原因(如何调试)? - HockeyApp launch my app and make it behave differently. What's the cause (how to debug)? Android 蓝牙打印机应用程序在调试模式下工作正常,但在发布模式下不起作用 - Android bluetooth printer app works fine in debug mode but doesn't work in release mode 关于 SSL,cordova“发布”的行为与“调试”不同 - cordova "release" behaves differently to "debug" regarding SSL Android POS打印机ESC / POS - Android POS Printer ESC/POS ESC/POS 热敏打印机。 通过 android 应用程序打印图像 - ESC/POS thermal printer. Printing an image via android app 如何添加打印机sdk POS系统android app - How add printer sdk POS system android app 将 USB POS 打印机与 Android 平板电脑上的应用程序集成 - Integrate USB POS printer with app from Android tablet 如何在构建 Android 应用程序的发布版本之前删除所有调试日志记录调用? - How to remove all debug logging calls before building the release version of an Android app? 检测 App android 是否处于 Debug 或 Release - Detect if the App android is in Debug or Release Android App可在调试中使用,但无法在发行版中使用 - Android App works in debug but not in release
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM