Camera of any emulator not working
Asked Answered
E

6

12

Friends

I am facing this issue since so long but i am able to get any kind of solution to get working camera in emulator. I have gone through all the answer of the SO but none helped me uptill now.

If i create any emulator with any api but in none of my emulator camera application does not work. So i am not able to test any of the application which contains camera functionality. I guess may be its happening because of the hardware configuration of my system. But i am not sure about it.

I do not know why this issue occurs. Please help me to solve and find out the reason for the issue.

Here is the error which i get whenever i starts camera in emulator.

12-21 00:04:58.100: E/CameraService(55): CameraService::connect X (pid 2604) rejected (invalid cameraId 0).
12-21 00:04:58.110: W/CameraBase(2604): An error occurred while connecting to camera: 0
12-21 00:04:58.110: E/CameraHolder(2604): fail to connect Camera
12-21 00:04:58.110: E/CameraHolder(2604): java.lang.RuntimeException: Fail to connect to camera service
12-21 00:04:58.110: E/CameraHolder(2604):   at android.hardware.Camera.native_setup(Native Method)
12-21 00:04:58.110: E/CameraHolder(2604):   at android.hardware.Camera.<init>(Camera.java:350)
12-21 00:04:58.110: E/CameraHolder(2604):   at android.hardware.Camera.open(Camera.java:309)
12-21 00:04:58.110: E/CameraHolder(2604):   at com.android.camera.CameraHolder.open(CameraHolder.java:131)
12-21 00:04:58.110: E/CameraHolder(2604):   at com.android.camera.Util.openCamera(Util.java:267)
12-21 00:04:58.110: E/CameraHolder(2604):   at com.android.camera.Camera$4.run(Camera.java:1100)
12-21 00:04:58.110: E/CameraHolder(2604):   at java.lang.Thread.run(Thread.java:841)
12-21 00:04:58.110: W/dalvikvm(2604): threadid=11: thread exiting with uncaught exception (group=0xb4a29b90)
12-21 00:04:58.120: E/AndroidRuntime(2604): FATAL EXCEPTION: Thread-117
12-21 00:04:58.120: E/AndroidRuntime(2604): Process: com.android.camera, PID: 2604
12-21 00:04:58.120: E/AndroidRuntime(2604): java.lang.RuntimeException: openCamera failed
12-21 00:04:58.120: E/AndroidRuntime(2604):     at com.android.camera.Util.openCamera(Util.java:272)
12-21 00:04:58.120: E/AndroidRuntime(2604):     at com.android.camera.Camera$4.run(Camera.java:1100)
12-21 00:04:58.120: E/AndroidRuntime(2604):     at java.lang.Thread.run(Thread.java:841)
12-21 00:04:58.120: E/AndroidRuntime(2604): Caused by: com.android.camera.CameraHardwareException: java.lang.RuntimeException: Fail to connect to camera service
12-21 00:04:58.120: E/AndroidRuntime(2604):     at com.android.camera.CameraHolder.open(CameraHolder.java:135)
12-21 00:04:58.120: E/AndroidRuntime(2604):     at com.android.camera.Util.openCamera(Util.java:267)
12-21 00:04:58.120: E/AndroidRuntime(2604):     ... 2 more
12-21 00:04:58.120: E/AndroidRuntime(2604): Caused by: java.lang.RuntimeException: Fail to connect to camera service
12-21 00:04:58.120: E/AndroidRuntime(2604):     at android.hardware.Camera.native_setup(Native Method)
12-21 00:04:58.120: E/AndroidRuntime(2604):     at android.hardware.Camera.<init>(Camera.java:350)
12-21 00:04:58.120: E/AndroidRuntime(2604):     at android.hardware.Camera.open(Camera.java:309)
12-21 00:04:58.120: E/AndroidRuntime(2604):     at com.android.camera.CameraHolder.open(CameraHolder.java:131)
12-21 00:04:58.120: E/AndroidRuntime(2604):     ... 3 more

Below are the options which i get while i am trying to edit emulator.

enter image description here Thanks.

Erythroblastosis answered 21/12, 2013 at 5:6 Comment(8)
You cannot use camera in emulator....Zorn
@Tamanna Who said you can not use camera in emulator ?Erythroblastosis
Did you try this ?Zorn
@Erythroblastosis are you using custom camera or opening default camera ??Maples
No simply trying to open camera using intent only in emulator. @CapDroidErythroblastosis
Enabling Hardware Acceleration solved the problem for me. You need to check Use Host GPU option in the Android AVD.Pigeonwing
I do not get any hardware acceleration option while editing emulator. See i have added SS while i edit emulator. @AndruErythroblastosis
Thsi will might helpful to you. #1276950Pigeonwing
E
23

I have resolved my issue by changing the emulators "Back Camera" property to Emulated as shown in screenshot.

enter image description here

Erythroblastosis answered 14/2, 2014 at 13:20 Comment(1)
how is this the correct answer? he's trying to get a webcam to work in the emulator and the solution is to just not use a webcam?Gomel
I
1

There is no declaration about Camera in limitation of Emulator in doc.

You can Enable camera in Emulator.But emulator wont show a realtime camera regardless.

As of Android SDK version 14, the emulator supports webcams to simulate a camera:

General notes - Added webcam support to Android 4.0 or later platforms to emulate rear-facing cameras when one webcam is present, and to emulate both rear-facing and front-facing cameras when two webcams are present. Webcam suport is for Windows and Linux only. Mac support will come in a later release.

Inspired answered 21/12, 2013 at 5:15 Comment(2)
There is not limitation of using camera in emulator i know it always work and i have used even in past.Erythroblastosis
Your answer is not useful to me.Erythroblastosis
P
1

Open Tools->Android->AVD Manager then click edit for your virtual device.Click Show Advanced Settings on your virtual device configuration window.Then camera settings field is turned on,select Emulated Front and Back.That is it.

Periodical answered 10/11, 2017 at 21:25 Comment(0)
S
0

I'm using Android Studio 3.1.1 in ubuntu 16.04 and had the same issue.
So after couple of days googling, finally solved my problem by myself. The Solution was:

  1. Edit the AVD and set the Emulated Performance/Graphics from Automatic to Software - GLES 1.1.
  2. Changed the SD Card size to 256 MB.
  3. Set only one of camera (e.g. Front) to webcam0 and other one to none or emulated.

Hope this helps others with the same problem.

Savannahsavant answered 12/5, 2018 at 6:39 Comment(0)
I
-1

JUST DO THIS

use emulated in both Front and back and then chage sdcard size

Illuminate answered 15/8, 2019 at 14:21 Comment(0)
P
-2

From the android documentation:

Emulator Limitations

No support for camera/video capture In other words, no, you cannot access or preview the camera in the emulator.

Potential answered 21/12, 2013 at 5:10 Comment(1)
Your answer is not useful to me.Erythroblastosis

© 2022 - 2024 — McMap. All rights reserved.