【问题标题】:DeadObject Exception occured. V7 smart pos Terminal发生死对象异常。 V7智能POS终端
【发布时间】:2018-07-18 17:32:06
【问题描述】:

我在 V7 POS 终端(打印模块)android 机器(V5.1.1)中工作。我已经在我的应用程序中配置了 SDK(Jar 文件)。服务器应用程序安装在 POS 机上。打印过程中出现问题。在这里,我已经包括了我的步骤。我被困在这个问题上超过一天。帮我修一下。

服务已启动。

public void startService(){
    Intent intent = new Intent();
    intent.setAction("com.justtide.service.dev.AIDL_SERVICE");
    intent.setPackage("com.justtide.service.dev");
    bindService(intent, mConnection, Service.BIND_AUTO_CREATE);
}

设备提供商

private ServiceConnection mConnection = new ServiceConnection() {

    @Override
    public void onServiceDisconnected(ComponentName name) {
    }

    @Override
    public synchronized void onServiceConnected(ComponentName name, IBinder service) {
        // TODO Auto-generated method stub
        mDeviceProvider = DeviceProvider.Stub.asInterface(service);

    }
};

打印机供应商

printerProvider =mDeviceProvider.getPrinterProvider();

printerProvider.fillStringFormat("TEST",PRINTER_FONT_SIZE_SMALL,PRINTER_FONT_TYPE_BOLD,PRINTER_ALIGNMENT_CENTER);
printerProvider.fillString("001420183990573");
int ret=-1;
try{
     ret =  printerProvider.print(); //  The Problem is occurred here.
    } catch (RemoteException e) {
        e.printStackTrace();
    }

这里我已将我的错误日志包含在 POS 机中。

错误选择的应用程序

com.example.justtidev7_demo I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@3e9ea6fc time:3027349
com.example.justtidev7_demo W/System.err: android.os.DeadObjectException
com.example.justtidev7_demo W/System.err:     at android.os.BinderProxy.transactNative(Native Method)
com.example.justtidev7_demo W/System.err:     at android.os.BinderProxy.transact(Binder.java:496)
com.example.justtidev7_demo W/System.err:     at com.justtide.service.dev.aidl.printer.PrinterProvider$Stub$Proxy.print(PrinterProvider.java:274)
com.example.justtidev7_demo W/System.err:     at 
com.justtide.dao.Printer.print(Printer.java:34)
com.example.justtidev7_demo W/System.err:     at 
com.justtide.activity.PrintActivity$3.run(PrintActivity.java:111)
com.example.justtidev7_demo W/System.err:     at java.lang.Thread.run(Thread.java:818)

错误无过滤器

    JustD: jdc_connect ...
02-08 15:36:51.577 15261-15276/? E/JavaBinder: *** Uncaught remote 
exception!  (Exceptions are not yet supported across processes.)
java.lang.NoSuchMethodError: No virtual method printerOpen()I in class 
Lcom/just/api/PosDevice; or its super classes (declaration of 
'com.just.api.PosDevice' appears in 
/system/framework/framework.jar:classes2.dex) at 
com.justtide.justtide.aq.d(Unknown Source) at justtide.PrintPicture.startPrint(Unknown Source) at com.justtide.service.dev.i.print(Unknown Source) at com.justtide.service.dev.aidl.printer.PrinterProvider$Stub.onTransact(Unknown Source) at android.os.Binder.execTransact(Binder.java:446)
02-08 15:36:51.577 15261-15276/? E/AndroidRuntime: FATAL EXCEPTION: Binder_1
Process: com.justtide.service.dev, PID: 15261
                                               java.lang.NoSuchMethodError: No virtual method printerOpen()I in class Lcom/just/api/PosDevice; or its super classes (declaration of 'com.just.api.PosDevice' appears in /system/framework/framework.jar:classes2.dex)
                                                   at com.justtide.justtide.aq.d(Unknown Source)
                                                   at justtide.PrintPicture.startPrint(Unknown Source)
                                                   at com.justtide.service.dev.i.print(Unknown Source)
                                                   at com.justtide.service.dev.aidl.printer.PrinterProvider$Stub.onTransact(Unknown Source)
                                                   at android.os.Binder.execTransact(Binder.java:446)

【问题讨论】:

    标签: java android thermal-printer printer-control-language


    【解决方案1】:

    已经一年多了,但是嘿......让我试着回答这个问题 未来的读者

    嗯,对于初学者来说,异常 DeadObjectException 仅仅意味着您正在调用的对象已经死亡,因为它的托管进程不再存在。

    我可以看到你没有取消绑定你的连接,你可能正在使用一个已经死的连接,但是你正在调用它的打印函数。 (你在泄露它,检查你的日志)

    我建议您尝试从PrinterProvider 捕获所有语句并在您的Application 类文件(即class App extends Application)上启动打印机连接,然后公开该对象并建立静态连接在您的活动中使用它,这样您就可以在需要或退出活动时绑定和取消绑定一次。

    public class App extends Application {
        protected App app;
        public static DeviceProvider deviceProvider;
        public static PrinterProvider printerProvider;
        public static UtilsProvider utils;
    
        private static ServiceConnection conn;
    
        @Override
        public void onCreate() {
            // TODO Auto-generated method stub
            super.onCreate();
            this.app = (App) getApplicationContext();
        }
    
        /* do your thing i.e connection, 
        * static methods for printing e.t.c expose them , 
        * use them in your activities
        */
    
    }
    

    或者,如果其中任何一个都没有任何意义,您可以随时向制造商索取一个有据可查的 SDK。

    希望这对某人有所帮助。 谢谢

    【讨论】:

    • 感谢您的回答。我在制造商支持的帮助下解决了这个问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-22
    • 1970-01-01
    • 1970-01-01
    • 2013-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多