Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 发生DeadObject异常。V7智能pos终端_Java_Android_Thermal Printer_Printer Control Language - Fatal编程技术网

Java 发生DeadObject异常。V7智能pos终端

Java 发生DeadObject异常。V7智能pos终端,java,android,thermal-printer,printer-control-language,Java,Android,Thermal Printer,Printer Control Language,我在V7 POS终端(打印模块)android机器(V5.1.1)中工作。我已经在我的应用程序中配置了SDK(Jar文件)。服务器应用程序安装在POS机上。打印过程中出现问题。这里我已经包括了我的步骤。我被这个问题困扰了一天多。帮我修一下 服务已启动。 public void startService(){ Intent intent = new Intent(); intent.setAction("com.justtide.service.dev.AIDL_SERVICE")

我在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();
    }
    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)
在这里,我已经在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)
无过滤器错误

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();
    }
    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)
已经一年多了,但是嘿。。。让我试着回答这个问题 未来读者

首先,异常
DeadObjectException
仅仅意味着您调用的对象已死亡,因为它的宿主进程不再存在

我可以看到,您没有解除连接绑定,并且您可能正在使用一个已经断开的连接,但是您正在对其调用print函数。(您正在泄漏,请检查日志)

我建议您尝试捕获
PrinterProvider
中的所有语句,并在应用程序类文件上启动打印机连接(即
类应用程序扩展应用程序
)公开该对象并建立静态连接,然后在活动中使用该连接,这样,您只能在需要或退出活动时绑定和解除绑定一次

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

希望这对别人有帮助。
谢谢你的回答。我已经在制造商支持的帮助下解决了这个问题。