2011-06-29 119 views
1

我嘗試運行this,但它強制關閉發生這樣爲什麼我無法打開相機?

06-29 10:14:14.154: ERROR/AndroidRuntime(4392): java.lang.RuntimeException: Fail to connect to camera service 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.hardware.Camera.native_setup(Native Method) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.hardware.Camera.<init>(Camera.java:294) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.hardware.Camera.open(Camera.java:271) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at com.example.Preview.surfaceCreated(Preview.java:37) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.SurfaceView.updateWindow(SurfaceView.java:543) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.SurfaceView.dispatchDraw(SurfaceView.java:348) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.ViewGroup.drawChild(ViewGroup.java:1644) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.ViewGroup.drawChild(ViewGroup.java:1644) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.ViewGroup.drawChild(ViewGroup.java:1644) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.View.draw(View.java:6936) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.widget.FrameLayout.draw(FrameLayout.java:357) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.ViewGroup.drawChild(ViewGroup.java:1646) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.ViewGroup.drawChild(ViewGroup.java:1644) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.View.draw(View.java:6936) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.widget.FrameLayout.draw(FrameLayout.java:357) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1904) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.ViewRoot.draw(ViewRoot.java:1527) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.ViewRoot.performTraversals(ViewRoot.java:1263) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1865) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.os.Handler.dispatchMessage(Handler.java:99) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.os.Looper.loop(Looper.java:123) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at android.app.ActivityThread.main(ActivityThread.java:3687) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at java.lang.reflect.Method.invokeNative(Native Method) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at java.lang.reflect.Method.invoke(Method.java:507) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
06-29 10:14:14.154: ERROR/AndroidRuntime(4392):  at dalvik.system.NativeStart.main(Native Method) 

回答

1

聽起來像您的設備不具備攝像頭(模擬器!),或者你沒有在你的清單中定義相應的權限。

android.permission.CAMERA 
+0

我已經在我的menifest中使用了但它仍然發生相同 – user790156

0

我認爲問題出在您的設備上,因爲本教程要求您添加權限。編輯你的AVD並在硬件中添加攝像頭支持

+0

我嘗試在我的設備上運行它(我的手機),但它仍然顯示出同樣的力量,我想要做什麼? – user790156

相關問題