开发者

Why does the android emulator camera stop unexpectedly?

I am using Android 2.2 (API Level 8). The camera is enabled in the manifest. When I try the camera icon provided by the emulator model, it runs for a few seconds showing a gray box moving around a black and white checkerboard, then dies with the error message:

Sorry! The application Camera (process com.android.camera) has stopped unexpectedly. Please try again.

Trying again, of course, doesn't help. I am using the provided emulator camera to compare behavior with a开发者_JS百科 camera application I am working on. Why does the android emulator camera stop unexpectedly?


The emulator camera is flaky at best.


To get more details run "platform-tools/adb logcat" from the host command line. The base problem seems to be the camera thinking there are multiple clients connected. The camera also sets the rotation to landscape but after crashing fails to set it back:

I/ActivityManager(   70): Starting: Intent { act=android.media.action.IMAGE_CAPTURE cmp=com.android.camera/.Camera } from pid 875
I/ActivityManager(   70): Start proc com.android.camera for activity com.android.camera/.Camera: pid=888 uid=10031 gids={1006, 1015}
I/WindowManager(   70): Setting rotation to 1, animFlags=1
I/ActivityManager(   70): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 orien=2 layout=34 uiMode=17 seq=22}
V/CameraHolder(  888): open camera 0
W/CameraService(   34): CameraService::connect X (pid 888) rejected (existing client).
E/CameraHolder(  888): fail to connect Camera
E/CameraHolder(  888): java.lang.RuntimeException: Fail to connect to camera service
E/CameraHolder(  888):  at android.hardware.Camera.native_setup(Native Method)
E/CameraHolder(  888):  at android.hardware.Camera.<init>(Camera.java:258)
E/CameraHolder(  888):  at android.hardware.Camera.open(Camera.java:220)
E/CameraHolder(  888):  at com.android.camera.CameraHolder.open(CameraHolder.java:124)
E/CameraHolder(  888):  at com.android.camera.Camera.ensureCameraDevice(Camera.java:1608)
E/CameraHolder(  888):  at com.android.camera.Camera.startPreview(Camera.java:1660)
E/CameraHolder(  888):  at com.android.camera.Camera.access$5500(Camera.java:95)
E/CameraHolder(  888):  at com.android.camera.Camera$3.run(Camera.java:908)
E/CameraHolder(  888):  at java.lang.Thread.run(Thread.java:1019)
W/dalvikvm(  888): threadid=11: thread exiting with uncaught exception (group=0x40015560)
E/AndroidRuntime(  888): FATAL EXCEPTION: Thread-12

See also question "4799183"


I would imagine because the emulator doesn't have a real camera, the hardware is simulated by the checkerbox you speak of. Because there is no hardware driver for real it most likely tries to check for capabilities, or set features that can't be done because the simulated hardware doesn't support it. Your best bet it to debug the camera or compile it yourself and add some debug output to find out what exactly is going on.


Does it work in 2.1 and earlier?

In the DDMS perspective I can see the exception shown here:

Emulator's camera built-in app buggy in Froyo / 2.2?

although I haven't tried the code change suggested in the article.

It might just be that the emulator camera is flaky :)


I have realized that camera simulation on the Emulator is stable on the API level 4 (Android 1.6) and below without crashing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜