Cannot run Android "Camera Preview" sample
Posted
by noisesolo
on Stack Overflow
See other posts from Stack Overflow
or by noisesolo
Published on 2010-06-08T20:48:33Z
Indexed on
2010/06/08
20:52 UTC
Read the original article
Hit count: 847
android
|android-sdk
The sample I'm referring to is: CameraPreview.
The program simply force closes upon start up. I've also tried other camera demos that have the same problem.
I'm trying to run the samples on my Nexus One and the emulator with the same problem on both. I'm not even sure if the emulator should be able to run them or not.
Based on LogCat, the error is:
06-08 16:39:10.483: ERROR/AndroidRuntime(6726): Uncaught handler: thread main exiting due to uncaught exception
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): java.lang.RuntimeException: Fail to connect to camera service
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.hardware.Camera.native_setup(Native Method)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.hardware.Camera.<init>(Camera.java:110)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.hardware.Camera.open(Camera.java:90)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at com.example.android.apis.graphics.Preview.surfaceCreated(CameraPreview.java:69)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.SurfaceView.updateWindow(SurfaceView.java:454)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.SurfaceView.dispatchDraw(SurfaceView.java:287)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.View.draw(View.java:6557)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.widget.FrameLayout.draw(FrameLayout.java:352)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.View.draw(View.java:6557)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.widget.FrameLayout.draw(FrameLayout.java:352)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1830)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.ViewRoot.draw(ViewRoot.java:1349)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.ViewRoot.performTraversals(ViewRoot.java:1114)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.os.Handler.dispatchMessage(Handler.java:99)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.os.Looper.loop(Looper.java:123)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.app.ActivityThread.main(ActivityThread.java:4363)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at java.lang.reflect.Method.invokeNative(Native Method)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at java.lang.reflect.Method.invoke(Method.java:521)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at dalvik.system.NativeStart.main(Native Method)
All I did to try out the sample was create a new Android 2.1update1 Project, named everything according to the supplied Java file, copied the Java file from the URL to the CameraPreview.java file, then run it. Am I supposed to do anything else?
Any help would be appreciated. Thanks in advance.
© Stack Overflow or respective owner