1

我使用 CommonsWare 库在我的 nexus 5 Android 6(锤击/锤击)上崩溃了cwac:cam2

当我改变录制/照片拍摄活动的方向时。该错误在我的设备上是系统性的。

堆栈跟踪 :

E / AndroidRuntime: FATAL EXCEPTION: main
Process: com.m360learning.android, PID: 9637
java.lang.RuntimeException: Unable to start activity ComponentInfo {
 com.m360learning.android / com.commonsware.cwac.cam2.VideoRecorderActivity
}: de.greenrobot.event.EventBusException: Subscriber class com.commonsware.cwac.cam2.CameraFragment already registered to event class com.commonsware.cwac.cam2.CameraController$ControllerReadyEvent
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 2476)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java: 4077)
at android.app.ActivityThread. - wrap15(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java: 1350)
at android.os.Handler.dispatchMessage(Handler.java: 102)
at android.os.Looper.loop(Looper.java: 148)
at android.app.ActivityThread.main(ActivityThread.java: 5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java: 726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java: 616)
Caused by: de.greenrobot.event.EventBusException: Subscriber class com.commonsware.cwac.cam2.CameraFragment already registered to event class com.commonsware.cwac.cam2.CameraController$ControllerReadyEvent
at de.greenrobot.event.EventBus.subscribe(EventBus.java: 179)
at de.greenrobot.event.EventBus.register(EventBus.java: 165)
at de.greenrobot.event.EventBus.register(EventBus.java: 133)
at com.commonsware.cwac.cam2.CameraFragment.onStart(CameraFragment.java: 123)
at android.app.Fragment.performStart(Fragment.java: 2244)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java: 1002)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java: 1148)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java: 1130)
at android.app.FragmentManagerImpl.dispatchStart(FragmentManager.java: 1958)
at android.app.FragmentController.dispatchStart(FragmentController.java: 163)
at android.app.Activity.performStart(Activity.java: 6274)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 2476) 
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java: 4077) 
at android.app.ActivityThread. - wrap15(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java: 1350) 
at android.os.Handler.dispatchMessage(Handler.java: 102) 
at android.os.Looper.loop(Looper.java: 148) 
at android.app.ActivityThread.main(ActivityThread.java: 5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java: 726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java: 616) 

非常感谢您的支持,修复非常迅速地实施。

4

1 回答 1

2

问题是您尝试注册服务两次,如您在跟踪中看到的那样在此处输入代码。该服务没有取消注册,因此对您来说最简单的选择是在注册之前检查服务是否已注册 EventBus.getDefault().isRegistered(...) 或检查 onStart 是事件服务没有停止,因此仍然挂号的。例如:

if (!EventBus.getDefault().isRegistered(this)) {
    EventBus.getDefault().register(this);
}
于 2016-02-29T18:26:22.810 回答