Make Android Emulator use physical usb camera - camera

Android Studio, latest Google SDK emulator. I have set back camera emulation mode to Webcam0 to get my usb camera connected to emulator. Unfortunately, it's not working. My camera works without any problems on host computer, for example this:
ffplay /dev/video0
gives me camera video playback. When I run emulator with above settings, camera on emulator just says "Unable connect to camera", then closes itself. Have anybody ever succeded with connecting physical camera to Android emulator? I have found some similar problems out there, but none of them has been resolved.

you can try to edit the config.ini of the AVD in ~/.android/avd/avd_name/config.ini like in this link http://viralpatel.net/blogs/enable-camera-in-android-emulator/ or use Android Studio directly like in this Android: How to use webcam in emulator?
if this isn't working see Lekensteyn's answer (2nd) in Connect USB device to Android Emulator?. it describes how a USB device can be passed through to a QEMU emulator. Android emulator is modified QEMU for more details see https://developer.android.com/studio/run/emulator-commandline.html
to find out if your webcam is recognized anyway try emulator #avd_name -webcam-list to get the available AVD use android list avd
more on passing through a USB device to QEMU emulator is also in https://unix.stackexchange.com/questions/250938/qemu-usb-passthrough-windows-guest

Related

react native ios emulator - how do I test camera function on computer, without using a phone?

I implemented code using a React Native package accessing camera to scan documents. I don't have a physical phone. How do I test the functionality using just my ios emulator on computer?
For iOS it's impossible to test the camera. For Android you can configure the emulator to do that.
Its possible to configure your emulator in Android to test the camera:
fire up Android Studio
open the AVD Manager screen
click on the pencil icon next to your chosen emulator device
show advanced settings
change camera (front and/or back) to "Webcam0"
You will need to cold restart your emulator for the changes to take effect.

open developer menu after install debug apk react-native

Currently, I'm working on a big tablet android like the advertisement board.
I'm trying to use react-native for it and the only port that they have is USB. I'm trying to open the developer menu but have no idea how. I am installing the apps by sending the debug apk using the drive.
Things that I try:-
shake the big tab, might be they do not have the sensor for it
use USB male to male did not detect the USB as adb or anything.
any idea how to open this one? it's pretty hard to not see the console.
Tab Information:
Model number
Quad-Core R18 ads
Android version
android 6.0.1
firmware version
ads_v1.0
kernel version
3.10.65
xiao#yh-Series2 #225

emulator-5554 unauthorized for adb devices

I'm trying to get my react-native project to run on an android emulator while on a Mac operating system. It worked fine on my windows.
On my Mac, I go to terminal and type react-native run-android and I get the error message:
$ react-native run-android
Scanning 616 folders for symlinks in /Users/John/Documents/myreactnativeproject/node_modules (17ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
I type adb devices and I see
List of devices attached
emulator-5554 unauthorized
I go into the settings of my android emulator, I go to Settings Build Number to tap it several times to enable Developer options. In developer options, I enabled USB debugging, disabled Verify apps over USB, and left everything else as default. I shut down my android studio and emulator, restarted it. But still, the same issues mentioned above.
What am I doing wrong?
EDIT
I just connected my android phone to my Mac. When I run adb devices, I see this result
List of devices attached
YLEDU16B18004313 device
But when I run react-native run-android, I get the same error as above. So maybe there is something wrong with my react-native set up instead?
EDIT 2
I was able to deploy the app to my android phone by adding these extra steps
chmod 755 android/gradlew
For some reason, when I type echo $ANDROID_HOME into the terminal, I get the result /Users/John/Library/Android/sdk. But if I add the echo $ANDROID_HOME line to my android/gradlew file, it echoes nothing. And when I run the react-native run-android command, the compiler complains that ANDROID_HOME is not defined. So I have to type export ANDROID_HOME=/Users/John/Library/Android/sdk again, then running the react-native run-android command works and deploys it to my phone.
However, my emulator still doesn't work. The new error message I get is that Skipping device 'emulator-5554' (emulator-5554): Device is UNAUTHORIZED,.
But at least I have a temporary solution, and to debug with my phone.
EDIT 3
I got rid of the emulator 5554 unauthorized error by going into my Android Virtual Devices and deleting the virtual device. Then I re-installed it. And now my adb devices shows emulator 5554 device. And I am not able to deploy the app to my emulator.
In my case, Create a Virtual Device with Google APIs Image, not Google Play Image worked for me.
The problem occurs the only emulator that runs on Android Pie others don't.
In Android Studio
Open an Android Virtual Device Manager.
Create a new Virtual Device.
Select any Hardware you want.
Select any System Image which the Target is "(Google APIs)" not "(Google Play)" (If you don't found. Try to look at "x86 Images" tab or "Other Images" tab)
Done!
Android emulators have by default "Usb Debugging" in settings. You just need to wipe the data of the emulator. Do the following steps. It will work :---
Close the emulator and run the command adb kill-server in the command prompt. If adb is not set in you path then you might run this command from directory where adb is present.
Click on Wipe Data option from avd Actions menu.
Now run the emulator. It should work.
create new Virtual Device, and make sure you choose Google API's.
run the new device!. this should work
In my case, following steps worked
Wipe data from avd manager
Cold boot now
I managed to authenticate the adb on a Pixel 2, Android 9.0 (Google Play), API 28, x86_64 virtual device (Intel HAXM). The problem should be related to the Extended Controls (the 3 dots bottom icon menu, when the virtual device is booted), the Google Play menu, that is checking the version of the Google Play services. When adb is not 'unauthorized', this page is displaying the correct version, and the Update button opens inside the phone the Play Store with the Play Services app, so you can update it.
The steps I took to be able to authenticate are:
Make sure the USB debugging is turned ON in Dev setting
Revoke the USB debugging authorizations
Make sure the Extended Controls > Settings > Advanced > Open GL options are set to the: 'Desktop native OpenGL' and 'Renderer maximum (up to OpenGL ES 3.1)', so the emulator interface, animations, etc, are fast!
Power off the emulator
In 'Your Virtual Devices' in Android Studio, click the down arrow in Actions > Select 'Cold Boot Now'
When the device boot, you have to be fast, the dialog to remember and accept the USB connection will show and disappear for like less than 1 second (again I guess related to some automation scripts kicking, idn).
If you manage to click the 'remember' and 'ok' checkbox and button before the dialog disappears, you are done. Else you have to Power Off and Cold Boot again.
After that, don't wipe your emulator, else you'll have to do that insane race clicking again!
I run adb kill-server and adb devices.
the device will back again.
for Emulator, the default settings is debug enabled
Creating an emulator with graphics set to "Software - GLES 2.0" worked for me (Nexus 6 image).
I was initially using a Nexus 5X image which didn't allow me to select the graphics option.
NOTE: I went through the steps mentioned in EDIT 2 and EDIT 3 by the OP before doing this.
This can happen if USB debugging is not enabled on the emulator device.
Go to the emulated device, enable the Developer options and enable USB debugging.
I had to create a new emulator with Google Api. Wiping data didn't work for me.
2022 answer
What a shame of thread: so many "answers", comments and upvotes and none worked. Nobody simply mentioned that the "adb unauthorized" is caused by the adb keys stored in ~/.android/adbkey and ~/.android/adbkey.pub After deleting and recreating them, the problem was solved.
Credit: Android Emulator Unauthorized
I got my mac system to deploy a react-native build to my physical phone by following Edit 2 in the question.
I got my mac system to deploy a react-native build to my emulator by following Edit 3 in the question.
I think the issue was generally caused by moving my project from a Windows dev area to Mac dev area. Then probably a combination of different issues happened that cause builds to fail for each situation.
Deleting emulator and creating it again helped me on Ubuntu
I solved Problem
add ANDROID_SDK_HOME to environment variable
ANDROID_SDK_HOME = D:\sdk
and unplug device
and use new cmd

'react-native run-android' with USB tethering not installing app on device (note 4)

I am trying to test my app through USB tethering (this app is currently working on Xcode and iOS Emulator). I have enabled tethering on 'Developer Options on my phone'
About Device
Samsung Note 4
Android 6.0.1
This is what i tried.
I ran this command
adb devices
react-native run-android
But the app is not installing on my Phone. Am i missing a step?
I've never done this with USB tethering. It seems like you need to do a bit more wiring to set up the app on your device outside of sharing internet connection. If you are open to an easy alternative you can try using Expo with create-react-native-app. If you have a simple app, you can run your code on your actual device by scanning a QR code.
The quickest way I've found to do test this out is with repl.it.

android sdk not showing my mobile connected on usb port

I'm new to Android.
I'm using Micromax A87 (india) with Gingerbread, this company is not listed in Android Manufacturers on Google website. My mobile's USB debugging mode is on. I tried to run hello world program with Eclipse but it started in AVD.
My problem is that my mobile is not showing in list by adb devices command. But device manager (win7) shows android composite ADB interface and I can also use my phone as disk.
Tell me where is issue? If I try to install supplied driver with phone then PC say that I already have better drivers and same case is for online search. I tried restarting adb.
Please help me to set up android work-space.
I have solved this issue for the same handset, do the following...
Go to C:\Users\system name.android
Make a copy of adb_usb.ini as a backup
Open adb_usb.ini
Replace the content of this file with following content:
0x17EF
0x1EBF
0x05C6
0x19D2
0x9015
0x1C9E
0x0BB4