Unfortunately, Camera has stopped

Mohammed Subhi Sheikh Quroush picture Mohammed Subhi Sheikh Quroush · Dec 8, 2015 · Viewed 11.3k times · Source

enter image description here

When I launch the Camera application I am getting this error, and this is my logcat.

12-08 12:50:10.393 2275-2369/com.android.launcher3 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa21675b0
12-08 12:50:10.509 965-3048/? E/CameraService: CameraService::connect X (PID 3209) rejected (invalid camera ID 0)
12-08 12:50:10.510 3209-3224/com.android.camera E/CameraHolder: fail to connect Camera
12-08 12:50:10.510 3209-3224/com.android.camera E/CameraHolder: java.lang.RuntimeException: Fail to connect to camera service
12-08 12:50:10.510 3209-3224/com.android.camera E/CameraHolder:     at android.hardware.Camera.<init>(Camera.java:495)
12-08 12:50:10.510 3209-3224/com.android.camera E/CameraHolder:     at android.hardware.Camera.open(Camera.java:341)
12-08 12:50:10.510 3209-3224/com.android.camera E/CameraHolder:     at com.android.camera.CameraHolder.open(CameraHolder.java:131)
12-08 12:50:10.510 3209-3224/com.android.camera E/CameraHolder:     at com.android.camera.Util.openCamera(Util.java:267)
12-08 12:50:10.510 3209-3224/com.android.camera E/CameraHolder:     at com.android.camera.Camera$3.run(Camera.java:1100)
12-08 12:50:10.510 3209-3224/com.android.camera E/CameraHolder:     at java.lang.Thread.run(Thread.java:818)
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime: FATAL EXCEPTION: Thread-179
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime: Process: com.android.camera, PID: 3209
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime: java.lang.RuntimeException: openCamera failed
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime:     at com.android.camera.Util.openCamera(Util.java:272)
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime:     at com.android.camera.Camera$3.run(Camera.java:1100)
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime:     at java.lang.Thread.run(Thread.java:818)
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime:  Caused by: com.android.camera.CameraHardwareException: java.lang.RuntimeException: Fail to connect to camera service
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime:     at com.android.camera.CameraHolder.open(CameraHolder.java:135)
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime:     at com.android.camera.Util.openCamera(Util.java:267)
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime:     at com.android.camera.Camera$3.run(Camera.java:1100) 
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime:     at java.lang.Thread.run(Thread.java:818) 
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime:  Caused by: java.lang.RuntimeException: Fail to connect to camera service
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime:     at android.hardware.Camera.<init>(Camera.java:495)
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime:     at android.hardware.Camera.open(Camera.java:341)
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime:     at com.android.camera.CameraHolder.open(CameraHolder.java:131)
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime:     at com.android.camera.Util.openCamera(Util.java:267) 
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime:     at com.android.camera.Camera$3.run(Camera.java:1100) 
12-08 12:50:10.511 3209-3224/com.android.camera E/AndroidRuntime:     at java.lang.Thread.run(Thread.java:818) 
12-08 12:50:10.671 954-954/? E/EGL_emulation: tid 954: eglCreateSyncKHR(1243): error 0x3004 (EGL_BAD_ATTRIBUTE)

and this is my config.ini

avd.ini.encoding=UTF-8
AvdId=Nexus_S_API_23
abi.type=x86
avd.ini.displayname=Nexus S API 23
disk.dataPartition.size=200M
hw.accelerometer=yes
hw.audioInput=yes
hw.battery=yes
hw.camera.back=webcam0
hw.camera.front=none
hw.cpu.arch=x86
hw.dPad=no
hw.device.hash2=MD5:37a2ff6e511626ba3ceddec8264474be
hw.device.manufacturer=Google
hw.device.name=Nexus S
hw.gps=yes
hw.gpu.enabled=yes
hw.keyboard=yes
hw.lcd.density=240
hw.mainKeys=yes
hw.ramSize=343
hw.sdCard=yes
hw.sensors.orientation=yes
hw.sensors.proximity=yes
hw.trackBall=no
image.sysdir.1=system-images\android-23\google_apis\x86\
runtime.network.latency=none
runtime.network.speed=full
runtime.scalefactor=auto
sdcard.size=100M
skin.dynamic=yes
skin.name=nexus_s
skin.path=C:\Program Files\Android\Android Studio\plugins\android\lib\device-art-resources\nexus_s
snapshot.present=no
tag.display=Google APIs
tag.id=google_apis
vm.heapSize=32

I also faced this error.

emulator -webcam-list -avd Nexus_S_API_23
emulator: WARNING: Increasing RAM size to 1GB
emulator: ERROR: camera_device_start_capturing: Device 'AndroidEmulatorVC0' is unable to save frame to the clipboard: 0

Note: I am getting an error when I am trying to download an image from the Android browser.

Answer

wseries picture wseries · Dec 12, 2015

Edit

Have you tried one of these ? It seems like your camera service didn't work properly / camera may be used for another application.

Failed to connect to camera service

Use the web camera in the android emulator


I use MacOSX by the way. i just say that, it works on my machine. I sent installed tools and logs. Maybe it helps.

VD Configuration

Nexus 5, API 23 (Both Cameras are selected)

When i start the emulator, it gives warning in the log but at in the end it worked.

Logs

WARNING: Camera name 'webcam0' is not found in the list of connected cameras.

12-12 22:59:15.060 2060-2079/com.android.camera V/CameraHolder: open camera 0
12-12 22:59:15.060 1019-1730/? I/CameraService: CameraService::connect call (PID 2060 "com.android.camera", camera ID 0) for HAL version default and Camera API version 1
12-12 22:59:15.060 1019-1730/? V/EmulatedCamera_Camera: getCameraInfo
12-12 22:59:15.060 1019-1730/? V/EmulatedCamera_BaseCamera: getCameraInfo
12-12 22:59:15.060 1019-1730/? W/AudioFlinger: acquireAudioSessionId() unknown client 2060 for session 7
12-12 22:59:15.060 1019-2081/? D/NuPlayerDriver: notifyListener_l(0xf619af80), (1, 0, 0)
12-12 22:59:15.060 1019-1730/? W/AudioFlinger: acquireAudioSessionId() unknown client 2060 for session 8
12-12 22:59:15.070 1019-2083/? D/NuPlayerDriver: notifyListener_l(0xf619afe0), (1, 0, 0)
12-12 22:59:15.070 1019-1730/? I/CameraClient: Opening camera 0
12-12 22:59:15.070 1019-1730/? V/EmulatedCamera_Camera: getCameraInfo
12-12 22:59:15.070 1019-1730/? V/EmulatedCamera_BaseCamera: getCameraInfo
12-12 22:59:15.070 1019-1730/? V/EmulatedCamera_Camera: connectCamera
12-12 22:59:15.070 1019-1730/? V/EmulatedCamera_QemuDevice: connectDevice
12-12 22:59:15.100 2059-2059/? D/AndroidRuntime: Calling main entry com.android.commands.pm.Pm
12-12 22:59:15.110 1019-1730/? V/EmulatedCamera_QemuDevice: connectDevice: Connected to device 'webcam0'
12-12 22:59:15.110 1019-1730/? V/EmulatedCamera_CallbackNotifier: setCallbacks: 0xf75d1505, 0xf75d1dba, 0xf75d1c92, 0xf75d2267 (0xf619b040)
12-12 22:59:15.110 1019-1730/? V/EmulatedCamera_CallbackNotifier: enableMessage: msg_type = 0xc0d
12-12 22:59:15.110 1019-1730/? V/EmulatedCamera_CallbackNotifier:     CAMERA_MSG_ERROR
12-12 22:59:15.110 1019-1730/? V/EmulatedCamera_CallbackNotifier:     CAMERA_MSG_FOCUS
12-12 22:59:15.110 1019-1730/? V/EmulatedCamera_CallbackNotifier:     CAMERA_MSG_ZOOM
12-12 22:59:15.110 1019-1730/? V/EmulatedCamera_CallbackNotifier:     CAMERA_MSG_PREVIEW_METADATA
12-12 22:59:15.110 1019-1730/? V/EmulatedCamera_CallbackNotifier: **** Currently enabled messages:
12-12 22:59:15.110 1019-1730/? V/EmulatedCamera_CallbackNotifier:     CAMERA_MSG_ERROR
12-12 22:59:15.110 1019-1730/? V/EmulatedCamera_CallbackNotifier:     CAMERA_MSG_FOCUS
12-12 22:59:15.110 1019-1730/? V/EmulatedCamera_CallbackNotifier:     CAMERA_MSG_ZOOM
12-12 22:59:15.110 1019-1730/? V/EmulatedCamera_CallbackNotifier:     CAMERA_MSG_PREVIEW_METADATA
12-12 22:59:15.120 1350-1374/system_process I/ActivityManager: Start proc 2086:com.android.defcontainer/u0a3 for service com.android.defcontainer/.DefaultContainerService
12-12 22:59:15.160 2086-2098/com.android.defcontainer D/DefContainer: Copying /data/local/tmp/com.example.volkangurol.myapplication to base.apk
12-12 22:59:15.210 1449-1449/com.android.systemui D/PhoneStatusBar: disable: < expand ICONS alerts SYSTEM_INFO back home* recent* clock search* quick_settings >
12-12 22:59:15.210 2060-2103/com.android.camera D/Camera: app passed NULL surface
12-12 22:59:15.210 1019-1619/? V/EmulatedCamera_Camera: getCameraInfo
12-12 22:59:15.210 1019-1619/? V/EmulatedCamera_BaseCamera: getCameraInfo
12-12 22:59:15.230 2060-2103/com.android.camera V/camera: Preview size is 640x480
12-12 22:59:15.230 1019-1019/? V/EmulatedCamera_Camera: setParameters
12-12 22:59:15.230 1019-1019/? D/EmulatedCamera_Camera: === Value changed: jpeg-quality: 90 -> 95
12-12 22:59:15.230 1019-1019/? D/EmulatedCamera_Camera: === Value changed: preview-frame-rate: 24 -> 30
12-12 22:59:15.230 1019-1019/? D/EmulatedCamera_Camera: +++ New parameter: recording-hint=false
12-12 22:59:15.230 2060-2103/com.android.camera V/camera: startPreview
12-12 22:59:15.230 1019-1380/? V/EmulatedCamera_Preview: setPreviewWindow: current: 0x0 -> new: 0x0
12-12 22:59:15.230 1019-1380/? V/EmulatedCamera_Camera: doStartPreview
12-12 22:59:15.230 1019-1380/? V/EmulatedCamera_Preview: startPreview
12-12 22:59:15.230 1019-1380/? D/EmulatedCamera_Camera: Starting camera: 640x480 -> NV21(yuv420sp)
12-12 22:59:15.230 1019-1380/? V/EmulatedCamera_QemuDevice: startDevice
12-12 22:59:15.230 1019-1380/? V/EmulatedCamera_Device: commonStartDevice: Allocated 0xf3f00000 460800 bytes for 307200 pixels in NV21[640x480] frame
12-12 22:59:15.230 1019-1380/? V/EmulatedCamera_QemuDevice: startDevice: Qemu camera device 'webcam0' is started for NV21[640x480] frames
12-12 22:59:15.230 1019-1380/? V/EmulatedCamera_Device: startDeliveringFrames
12-12 22:59:15.230 1019-1380/? V/EmulatedCamera_Device: startWorkerThread
12-12 22:59:15.260 1019-2104/? V/EmulatedCamera_Device: Starting emulated camera device worker thread...

enter image description here