0

I have started a service and when I wanted to unbind and stop that service, all of a sudden, I that error occured.

here is the complete error:

    W/System.err: java.io.IOException: bt socket closed, read return: -1
    I/3: thread id:
        activity1 destroyed
    W/System.err:     at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:573)
            at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:96)
            at java.io.InputStream.read(InputStream.java:162)
            at com.example.myapplication.PrinterService$ConnectedThread.run(PrinterService.java:369)
    I/art: Background sticky concurrent mark sweep GC freed 60953(5MB) AllocSpace objects, 14(9MB) LOS objects, 0% free, 89MB/89MB, paused 70.915ms total 2.205s
    I/art: Background partial concurrent mark sweep GC freed 43729(5MB) AllocSpace objects, 1(2MB) LOS objects, 14% free, 91MB/107MB, paused 857us total 179.158ms
    I/art: Background partial concurrent mark sweep GC freed 36181(4MB) AllocSpace objects, 4(14MB) LOS objects, 14% free, 94MB/110MB, paused 838us total 155.295ms
    I/art: Background partial concurrent mark sweep GC freed 42835(5MB) AllocSpace objects, 1(10MB) LOS objects, 13% free, 99MB/115MB, paused 859us total 186.076ms
    I/art: Background partial concurrent mark sweep GC freed 28759(3MB) AllocSpace objects, 1(15MB) LOS objects, 12% free, 107MB/123MB, paused 870us total 173.901ms
    W/art: Suspending all threads took: 73.754ms
    I/art: Background sticky concurrent mark sweep GC freed 116369(14MB) AllocSpace objects, 0(0B) LOS objects, 0% free, 141MB/141MB, paused 74.892ms total 99.677ms
    I/art: Background partial concurrent mark sweep GC freed 33833(4MB) AllocSpace objects, 1(23MB) LOS objects, 11% free, 118MB/134MB, paused 1.203ms total 190.147ms
    I/art: Background sticky concurrent mark sweep GC freed 53273(6MB) AllocSpace objects, 0(0B) LOS objects, 0% free, 170MB/170MB, paused 1.127ms total 146.272ms
    I/art: Background partial concurrent mark sweep GC freed 31611(3MB) AllocSpace objects, 1(34MB) LOS objects, 10% free, 135MB/151MB, paused 913us total 168.414ms
    I/art: Background sticky concurrent mark sweep GC freed 96667(11MB) AllocSpace objects, 0(0B) LOS objects, 0% free, 218MB/218MB, paused 1.433ms total 152.804ms
    E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.example.myapplication, PID: 4230
        java.lang.StackOverflowError: stack size 8MB
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.
    I/art: Background partial concurrent mark sweep GC freed 18(2336B) AllocSpace objects, 1(51MB) LOS objects, 7% free, 207MB/223MB, paused 1.196ms total 354.004ms
    I/art: Background partial concurrent mark sweep GC freed 47469(5MB) AllocSpace objects, 5(131MB) LOS objects, 13% free, 101MB/117MB, paused 897us total 231.154ms
    W/art: Suspending all threads took: 5.608ms
    I/art: Background sticky concurrent mark sweep GC freed 60577(7MB) AllocSpace objects, 0(0B) LOS objects, 0% free, 115MB/117MB, paused 6.614ms total 77.771ms
    I/art: Background partial concurrent mark sweep GC freed 50265(6MB) AllocSpace objects, 2(17MB) LOS objects, 13% free, 99MB/115MB, paused 843us total 182.564ms
    I/art: Background partial concurrent mark sweep GC freed 38932(4MB) AllocSpace objects, 1(15MB) LOS objects, 13% free, 106MB/122MB, paused 833us total 158.449ms
    I/art: Background partial concurrent mark sweep GC freed 46551(5MB) AllocSpace objects, 1(23MB) LOS objects, 11% free, 118MB/134MB, paused 910us total 178.363ms
    I/art: Background sticky concurrent mark sweep GC freed 39530(4MB) AllocSpace objects, 0(0B) LOS objects, 0% free, 169MB/169MB, paused 894us total 103.542ms
    I/art: Background partial concurrent mark sweep GC freed 38234(4MB) AllocSpace objects, 1(34MB) LOS objects, 10% free, 135MB/151MB, paused 953us total 161.963ms
    D/Error: ERR: exClass=java.lang.StackOverflowError
    D/Error: ERR: exMsg=stack size 8MB
        ERR: file=PrinterService.java
        ERR: class=com.example.myapplication.PrinterService
        ERR: method=unbindService line=68
    W/art: Suspending all threads took: 178.685ms
    I/art: Background partial concurrent mark sweep GC freed 42(1027KB) AllocSpace objects, 1(51MB) LOS objects, 7% free, 207MB/223MB, paused 179.817ms total 436.403ms
    D/Error: ERR: stack=java.lang.StackOverflowError: stack size 8MB
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplication.PrinterService.unbindService(PrinterService.java:68)
            at com.example.myapplicatio
    D/Error: ERR: TOTAL BYTES WRITTEN: 43431876
    E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 43431960)
    E/AndroidRuntime: Error reporting crash
        android.os.TransactionTooLargeException: data parcel size 43431960 bytes
            at android.os.BinderProxy.transactNative(Native Method)
            at android.os.BinderProxy.transact(Binder.java:511)
            at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerNative.java:4473)
            at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:103)
            at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
            at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
    D/Process: killProcess, pid=4230
    D/Process: com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException:113 java.lang.ThreadGroup.uncaughtException:693 java.lang.ThreadGroup.uncaughtException:690 



here is onDestroy method in MainActivityOrig.class:

     @Override
    protected void onDestroy() {
        Log.i("3","thread id:\n"+"activity1 destroyed");
        isServiceBound = false;
        if (printerService!=null){ 
            printerService.stopService((new Intent(getBaseContext(), PrinterService.class)));
            printerService.unbindService(serviceConnection); 
        }
        super.onDestroy();
    }

and here is unbindService method in Printerservice:

@Override
public void unbindService(ServiceConnection conn) {
    unbindService(conn);
}

as well, stopService method that is available in service is here:

public boolean stopService(Intent name) {
        setState(STATE_NONE);
        if (mConnectThread != null) {
            mConnectThread.cancel();
            mConnectThread = null;
        }

        if (mConnectedThread != null) {
            mConnectedThread.cancel();
            mConnectedThread = null;
        }
        started=0;
        mBluetoothAdapter.cancelDiscovery();
        return super.stopService(name);
    }

in fact I am using Bluetooth service that is available in the following link:

How to move Bluetooth activity into a Service

I have this error while exiting application.

mohammad
  • 1
  • 1

0 Answers0