Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Emulator not using webcam in Android Studio

Tags:

android

camera

As the title suggests, I'm struggling to get the emulator use the webcam on the laptop. I have enabled the front and back camera to access the webcam. Whenever the emulator boots up it asks for webcam access, which I grant. However the webcam never works when I hit the camera app on the emulator. The camera app just crashes.

Here is an image enabling the cameras:

enter image description here

Based on other posts on StackOverflow, suggesting i add the line: hw.camera=yes. Below is the config file for the avd.

avd.ini.encoding=UTF-8
AvdId=Nexus_5_API_21_x86
abi.type=x86
avd.ini.displayname=Nexus 5 API 21 x86
disk.dataPartition.size=1G
hw.accelerometer=yes
hw.audioInput=yes
hw.battery=yes
hw.camera=yes
hw.camera.back=webcam0
hw.camera.front=webcam0
hw.cpu.arch=x86
hw.dPad=no
hw.device.hash2=MD5:2fa0e16c8cceb7d385183284107c0c88
hw.device.manufacturer=Google
hw.device.name=Nexus 5
hw.gps=yes
hw.gpu.enabled=yes
hw.keyboard=yes
hw.lcd.density=480
hw.mainKeys=no
hw.ramSize=1536
hw.sdCard=yes
hw.sensors.orientation=yes
hw.sensors.proximity=yes
hw.trackBall=no
image.sysdir.1=system-images\android-21\google_apis\x86\
runtime.network.latency=none
runtime.network.speed=full
runtime.scalefactor=auto
sdcard.path=C:\Users\Roberto\.android\avd\Nexus_5_API_21_x86.avd\sdcard.img
skin.dynamic=no
skin.name=nexus_5
skin.path=C:\Program Files\Android\Android Studio1\plugins\android\lib\device-art-resources\nexus_5
snapshot.present=no
tag.display=Google APIs
tag.id=google_apis
vm.heapSize=64

At this stage I'm not sure why this is not working. Any thoughts?

like image 449
user481610 Avatar asked Jun 15 '15 16:06

user481610


People also ask

Can't connect to the camera emulator?

Go to Android Virtual device manager>>select the emulator>>click edit>>select Advanced Setting>>camera select as Emulated rather than Webcam0 . Save this answer.

How do I enable Android emulator in Visual Studio?

Just open up the Visual Studio Emulator for Android entry in your Start Menu, hit play, and the emulator is ready to debug from any IDE. Download the standalone emulator today!


1 Answers

I don't think you can set both front and back cameras to the same value. Please try to edit your config.ini file and change to this: hw.camera.back=none hw.camera.front=webcam0

Also, hw.camera=yes is not needed.

I hope that helps.

like image 91
Talobin Avatar answered Sep 29 '22 10:09

Talobin