Android Emulator: Unable to start webcam to capture picture in emulator

后端 未结 5 1549
长发绾君心
长发绾君心 2021-02-03 19:54

I have created an armeabi API 21 emulator in the AVD manager in Android Studio, set it to use the webcam as a front camera, and launched it. The problem is that it\'s not able t

相关标签:
5条回答
  • 2021-02-03 20:17

    In Android Studio, go to AVD Manager, click on edit (pencil) button in Actions. After that, in next appearing window, click on Advance settings, and then scroll down and in Camera options, select webcam for front and back.

    0 讨论(0)
  • 2021-02-03 20:21

    I had trouble getting the camera to work under the emulator (under linux), even after setting it up in AVD as instructed here. I was helped by noticing that the camera it was trying to use was /dev/video0, but the camera I wanted was /dev/video3. A quick swap...

    mv /dev/video0 /dev/video4
    mv /dev/video3 /dev/video0
    

    ...did the trick

    Change /dev/video6 into /dev/video0

    0 讨论(0)
  • 2021-02-03 20:24

    To enable Camera in your Android Emulator, just add following highlighted code in your AVD’s config.ini file. You can find the config.ini file under your <userdirectory>/.android folder.

    File: ~/.android/config.ini

    hw.lcd.density=160<br>
    skin.name=HVGA<br>
    skin.path=platforms\android-9\skins\HVGA<br>
    hw.cpu.arch=arm<br>
    abi.type=armeabi<br>
    vm.heapSize=24<br>
    image.sysdir.1=platforms\android-9\images\<br>
    hw.camera=yes<br>
    sdcard.size=64M<br>
    

    In case you don’t find the config.ini file or want to enable Camera support through Android SDK and AVD Manager do the following:

    Open Android SDK and AVD Manager:

    1. Add SD Card in AVD
      In the SD Card setting, set the value for Size. To enable camera, the SD Card must be enabled in Emulator.
    2. Add Camera Support in Hardware under AVD
      Now under Hardware section, click New button to add Camera hardware. It will open following Dialog box. Select Camera support from the Property dropdown and click Ok.
    3. Enable Camera Support in Hardware
      The new hardware: Camera support is visible under Hardware section. Set its value to yes and save changes by pressing Edit AVD.
    4. Save the changes and launch the emulator.
    0 讨论(0)
  • 2021-02-03 20:26

    You can try to manually edit your AVD's configuration file under

    ~/.android/avd/yourAvdName/config.ini

    by adding this line:

    hw.camera=yes
    

    UPDATE

    You can try to specify the real resolution of your webcam:

    hw.camera.maxHorizontalPixels=XXX
    hw.camera.maxVerticalPixels=XXX
    

    Keep in mind that the default value for maxHorizontalPixels is 640 and for maxVerticalPixels is 480, so chaning this values may help you to solve your issues.

    0 讨论(0)
  • 2021-02-03 20:29

    I had a similar issue with a slightly different error message under OS X. I turned out that everything was ok but the emulator is crashing when the camera takes too much time to initialize.

    I my case I ended up closing other applications and it worked. You may want to test in a more performant computer.

    0 讨论(0)
提交回复
热议问题