title: Solving 'application has stopped' crash errors
body: <p>Building an AOA application, my Android device communicates with an external accessory, in this case an arduino.</p>
  
  <p>When I connect the accessory, my Android application launches correctly as I have a USB_ATTACHED action within my intent-filter for my mainActivity.</p>
  
  <p>However, my Android application unfortunately crashes when disconnected from the USB accessory.</p>
  
  <p>My shell immediately switches from TCPIP to USB mode on disconect but reconnecting I get a complete stack trace</p>
  
  <p>Can any Android gurus suggest how I might debug this further based on the following logcat output?</p>
  
  <pre><code>E/run     ( 5092): java.io.IOException: read failed: EIO (I/O error)
  D/PicasaSyncManager( 4877): battery info: false
  D/UsbDeviceManager(  781): exited USB accessory mode
  E/UsbDebuggingManager(  781): got -1 reading
  E/UsbDebuggingManager(  781): Communication error: 
  E/UsbDebuggingManager(  781): java.io.IOException: No such file or directory
  E/UsbDebuggingManager(  781):   at android.net.LocalSocketImpl.connectLocal(Native Method)
  E/UsbDebuggingManager(  781):   at android.net.LocalSocketImpl.connect(LocalSocketImpl.java:287)
  E/UsbDebuggingManager(  781):   at android.net.LocalSocket.connect(LocalSocket.java:130)
  E/UsbDebuggingManager(  781):   at com.android.server.usb.UsbDebuggingManager.listenToSocket(UsbDebuggingManager.java:75)
  E/UsbDebuggingManager(  781):   at com.android.server.usb.UsbDebuggingManager.run(UsbDebuggingManager.java:111)
  E/UsbDebuggingManager(  781):   at java.lang.Thread.run(Thread.java:841)
  D/dalvikvm(  781): GC_FOR_ALLOC freed 1069K, 14% free 31156K/35896K, paused 54ms, total 55ms
  V/SearchControllerCache( 2819): creating SearchController
  W/Sidekick_LocationOracleImpl( 2819): Best location was null
  D/dalvikvm( 2819): GC_FOR_ALLOC freed 514K, 5% free 18100K/18940K, paused 15ms, total 15ms
  D/audio_hw_primary(  182): select_devices: out_snd_device(0: ) in_snd_device(35: voice-rec-mic)
  D/        (  182): Failed to fetch the lookup information of the device 0000003E 
  E/ACDB-LOADER(  182): Error: ACDB AudProc vol returned = -19
  I/SearchController( 2819): #onHotwordDetectorStarted
  D/MainActivity( 5092): ASSERT registerPhone and register =false
  D/MainActivity( 5092): ASSERT registerSms and register =false
  I/WroxAccessory( 5092): disconnect
  D/AndroidRuntime( 5092): Shutting down VM
  W/dalvikvm( 5092): threadid=1: thread exiting with uncaught exception (group=0x41e7cba8)
  E/AndroidRuntime( 5092): FATAL EXCEPTION: main
  E/AndroidRuntime( 5092): Process: ca.foo, PID: 5092
  E/AndroidRuntime( 5092): java.lang.RuntimeException: Unable to destroy activity {ca.foo/ca.foo.MainActivity}: java.lang.IllegalArgumentException: Receiver not registered: com.wiley.wroxaccessories.UsbConnection12$1@42f0be28
  E/AndroidRuntime( 5092):    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3497)
  E/AndroidRuntime( 5092):    at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3515)
  E/AndroidRuntime( 5092):    at android.app.ActivityThread.access$1400(ActivityThread.java:135)
  E/AndroidRuntime( 5092):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1249)
  E/AndroidRuntime( 5092):    at android.os.Handler.dispatchMessage(Handler.java:102)
  E/AndroidRuntime( 5092):    at android.os.Looper.loop(Looper.java:136)
  E/AndroidRuntime( 5092):    at android.app.ActivityThread.main(ActivityThread.java:5017)
  E/AndroidRuntime( 5092):    at java.lang.reflect.Method.invokeNative(Native Method)
  E/AndroidRuntime( 5092):    at java.lang.reflect.Method.invoke(Method.java:515)
  E/AndroidRuntime( 5092):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
  E/AndroidRuntime( 5092):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
  E/AndroidRuntime( 5092):    at dalvik.system.NativeStart.main(Native Method)
  E/AndroidRuntime( 5092): Caused by: java.lang.IllegalArgumentException: Receiver not registered: com.wiley.wroxaccessories.UsbConnection12$1@42f0be28
  E/AndroidRuntime( 5092):    at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:667)
  E/AndroidRuntime( 5092):    at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1453)
  E/AndroidRuntime( 5092):    at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:489)
  E/AndroidRuntime( 5092):    at com.wiley.wroxaccessories.UsbConnection12.close(UsbConnection12.java:115)
  E/AndroidRuntime( 5092):    at ca.foo.MainActivity.onDestroy(MainActivity.java:164)
  E/AndroidRuntime( 5092):    at android.app.Activity.performDestroy(Activity.java:5403)
  E/AndroidRuntime( 5092):    at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1117)
  E/AndroidRuntime( 5092):    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3484)
  E/AndroidRuntime( 5092):    ... 11 more
  </code></pre>