解决'应用已停止'崩溃错误

时间:2014-01-22 22:21:07

标签: android crash wifi stack-trace logcat

构建AOA应用程序,我的Android设备与外部附件通信,在这种情况下是arduino。

当我连接附件时,我的Android应用程序正确启动,因为我的mainActivity的intent-filter中有USB_ATTACHED操作。

但是,我的Android应用程序很可能在断开USB附件时崩溃。

我的shell在断开连接后立即从TCPIP切换到USB模式但重新连接我得到完整的堆栈跟踪

任何Android专家都可以根据以下logcat输出建议我如何进一步调试吗?

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

3 个答案:

答案 0 :(得分:2)

对于抛出的IO错误, 我遇到了:

https://code.google.com/p/android/issues/detail?id=20545

一个选项是在onPause()中编写一个函数, 但更好的方法是:(如同一链接中#9所述) - 使用http://developer.android.com/guide/topics/manifest/activity-element.html#lmode

此外,还有一个问题是要正确关闭USB配件连接,这对您的情况有帮助 Proper way to close a USB accessory connection

答案 1 :(得分:1)

坦率地说,因为我对你的第一个例外不是很熟悉,所以我试图对它进行一些研究,看起来最相关的描述是它是一个ICS错误 - 你可以阅读它{{ 3}},但我看不到arduino和NFS之间的关系。

第二个对我来说更加熟悉。我不知道它是否是唯一一个可能产生它的情况(可能不是),但在我的情况下,这是因为在registerReceiver(...)我传递了两个Context s,并且在{{ 1}}它完全失败了。解决方案是将unregisterReceiver(...)作为注册上下文传递,此异常停止显示。

答案 2 :(得分:1)

只需清除缓存/数据该应用程序的数据,然后重新启动设备即可。希望一切都会正常