Android Emulator not using webcam in Android Studio
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:
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-imagesandroid-21google_apisx86
runtime.network.latency=none
runtime.network.speed=full
runtime.scalefactor=auto
sdcard.path=C:UsersRoberto.androidavdNexus_5_API_21_x86.avdsdcard.img
skin.dynamic=no
skin.name=nexus_5
skin.path=C:Program FilesAndroidAndroid Studio1pluginsandroidlibdevice-art-resourcesnexus_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?
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.
I just had the same problem that the webcam would not start when I started the build from the "Run" tab on Android Studio 3.01. I then opened the AVD manager. In Edit mode for the Android 5.1 device and made sure to bump the SD card to 200M, both front/back set to webcam0 for the device I was emulating. Then closed the Edit mode and just double clicked on the device - and it worked!
链接地址: http://www.djcxy.com/p/85856.html上一篇: 如果文字超过特定长度,则应用CSS