The camera of any emulator does not work

Friends

I have encountered this problem for so long, but I can get any solution for the working camera to work in the emulator. I went through the whole SO answer, but none of them helped me now.

If I create any emulator with any api, but the camera does not work in any of my emulators. Therefore, I cannot check out any application that contains camera functions. I think this may be due to the hardware configuration of my system. But I'm not so sure about that.

I do not know why this problem occurs. Please help me solve and find out the cause of the problem.

Here is the error that I get whenever I launch the camera in the 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 that I get while I try to edit the emulator.

enter image description here Thank you

+7
source share
7 answers

I solved the problem by changing the property of the "Back Camera" emulators to Emulated , as shown in the screenshot.

enter image description here

+13
source

Open "Tools" → Android-> AVD Manager, then click "Edit" for your virtual device. Click "Show advanced settings" in the configuration window of your virtual device. After turning on the camera settings field, select "Emulated Front" and "Back". It's all.

+2
source

Camera Expression does not have a doc emulator restriction announcement.

You can enable the camera in the emulator . But the emulator will not show the camera in real time.

Starting with the Android SDK version 14 , the emulator supports webcams to simulate a camera:

General notes. Added webcam support for Android 4.0 or later platforms. emulate rear view cameras when one webcam is present, and emulate both rear and front cameras when two webcams are present. Webcam support is for Windows and Linux only. Mac support comes later.

0
source

I am using Android Studio 3.1.1 on Ubuntu 16.04 and had the same problem.
So after several days of searching, finally solved my problem on my own. The solution was:

  1. Edit AVD and set emulated performance / graphics from automatic to software - GLES 1.1 .
  2. Resized SD card to 256 MB .
  3. Install only one camera (for example, the front) on the webcam0, and the other on zero or emulate.

Hope this helps others with the same issue.

0
source

Can this edit Android, work all the emulator like MEmu My camera is not good. My camera shows black and white on the screen

0
source

JUST DO IT

use emulated both front and back and then resize sdcard

-1
source

From the documentation for Android:

Emulator Limitations

There is no support for capturing the camera / video In other words, no, you cannot access or view the camera in the emulator.

-2
source

All Articles