Connect USB device to Android Emulator? - android

We've been looking into Android 3.1+ and its ability to read/write to USB devices connected to the OTG/Host port.
I've found some code examples that allow me to detect and read/write to a USB HID device, but at the moment, I simply don't have a physical 3.1+ compatible device to deploy and remotely debug on.
Does anyone know how I can attach my HID device to the emulator, via the PC/Eclipse so the app can detect and read/write to/from the device?
I've tried listing the currently connected USB Devices but it shows none, as you'd no doubt guess.
Any ideas?
Cheers

The Android emulator is based on QEMU. Even if the emulator version is so ancient, there appears to be support for passing USB devices from the host. It does not seem to be available for ARM devices though, the emulated ARM machine does not have a USB controller. (I have already tried enabling all USB host controllers for the goldfish_armv7 kernel based on Linux 3.4, without luck. The default emulator goldfish_armv7 kernel does not even have Host USB enabled.)
If you are not limited to ARM and can use x86, then I suggest to check out http://www.android-x86.org/, its images can be used with a standard QEMU i386 (or x86_64) machine. This also yields better performance by using the KVM extension on Linux.
To passthrough a USB device with of vendor ID 1234 and device ID abcd, you can run the emulator command:
emulator -avd x86-machine -qemu -usb -usbdevice host:1234:abcd
Or, when using QEMU:
qemu-system-i386 -m 1G -cdrom android-x86.iso -usb -usbdevice host:1234:abcd
You will need read/write permissions for /dev/bus/usb/XXX/YYY, for that you can create a udev rule such as:
SUBSYSTEM!="usb", GOTO="end_skip_usb"
ATTRS{idVendor}=="1234", ATTRS{idProduct}=="abcd", TAG+="uaccess"
LABEL="end_skip_usb"
Now, upon insertion of the USB device, your emulator should recognize a USB device. This is tested for a Linux installation with a Android x86 4.3 image.

AFAIK this isn't possible. Android emulators do not emulate many things that exist in real devices... but this reminds me of an attempt to run ADB over Bluetooth.
This isn't a direct positive answer to your question but perhaps it can help you find a workaround the way I did: Install an "emulator" on a physical x86 netbook (dual-boot) and use the links referred to in my posts to accomplish what you are trying to do via WiFi or Bluetooth.
Hope this helps.

Create android Virtual Machine on virtualBox or vm player with this image.
Connect USB and connect with Eclipse using ADB connect (your device IP).

Installed android guest in virtualbox with Windows 7 host using image android-x86-4.0-r1-eeepc.iso from here (because my company's computer locked bios and I couldn't enable the vt-x emulation I had to install a version prior to 4.4). Then pluged in a usb drive, opened VM - Settings - USB in Virtualbox Manager, clicked the second icon on the right with a plus sign on it, chose the usb drive. Virtualbox then installed driver for the USB drive. After it finished, booted the android VM. Started OpenManager, went to mnt/USB, and files of the usb drive were there!

Related

macOS Sierra doesn't detect USB connected Pine64 with Android

I hope someone will be able to help me. I've been trying to make it work for days.
My goal is to use the Pine64 with Android and the touchscreen to debug a game using Unity Remote.
The board is PineA64+ 1GB, the touchscreen is the one from the Pine64 store, the SD card is the 32GB card from the store, and the Android is the 6.0.1 for LCD (http://wiki.pine64.org/index.php/Pine_A64_Software_Release#Android_6.0.1_.28LCD_Panel_Video_Output.29_.5B20170209.5D).
My computer OS is macOS Sierra (10.12.6).
I've installed the Android SDK using Android Studio (version 23.0.3 of the build-tools, since I use Android 6.0.1). When I use 'adb devices' to list the devices, it is not listed. But when I go to System Information to check if it's even detected, under Hardware > USB, nothing appears. So it seems that is not that 'adb' doesn't recognize the device, but the USB connection doesn't appear to be there; the computer doesn't detect it.
USB debugging is on, I've tried changing the USB mode between MTP and PTP, I've tried different USB ports from my laptop (if I connect my phone, Android too, it works in both), I've tried different USB cables, I've tried the different USB ports in the board (using Linux the USB ports work well, so I assume is something with Android, and not the board). I've also tried adding the vendor id in adb_usb.ini, as indicated in adb not finding my device / phone (MacOS X)
Could anyone help me? Should I use Android 5.1.1? Do I need to change some configuration, or install some app?
Thank you and best regards.

VirtualBox Ubuntu 12.04 (64-bit) Guest Not Recognizing Android Device

I've setup an Ubuntu 12.04 LTS 64-bit VirtualBox guest running on a Windows 7 host (also 64-bit) with the sole purpose of Android-based hacking, programming, debugging, etc. I've followed numerous guides and forums in order to have my VBox guest recognize my physical Android device via USB, but I keep getting the following error pop-up:
Failed to attach the USB device motorola XT926 [0228] to the virtual machine Android.
USB device 'motorola XT926' with UUID {REDACTED} is busy with a previous request. Please try again later.
Result Code: E_INVALIDARG (0x80070057)
Component: HostUSBDevice
Interface: IHostUSBDevice {REDACTED}
Callee: IConsole {REDACTED}
I've tried the following:
Note that I've already uninstalled VirtualBox, reinstalled the latest version, installed the VirtualBox Guest Additions as well as the latest expansion pack
Shutdown VM
Plug in Android device via USB and allow Windows to recognize it
Run "VboxManage list usbhost" to confirm that the device is being recognized by VBox and listed as "Available"
Edit VM settings to enable USB Controller AND USB 2.0 (EHCI) Controller.
Add filter for Motorola device (VendorID = 22b8) and set Remote option to "Any"
Unplug Android device
Start VM, login and wait for it to "settle"
Plug in Android device
I've also tried the following:
echo Y into the old_schema_first config
create 70-android.rules with the appropriate SUBSYSTEM, ATTR and MODE values set
The guest VM still does not recognize the Android device and abd doesn't list any when I issue the adb devices command.
Any help here would be greatly appreciated.
If your device support adb wireless debug (like Nexus), use that. If not, you can install adbWiress, this app makes your device debugable through wifi (need root).

Android adb is unable to find Teclast G18 tpad for on mac os

Android adb can't detect Telcast G18 tpad for mac os. I've run
adb kill-server
to stop the adb daemon and run
adb start-server
to restart the adb daemon. But still failed to make adb recognize it?
According to this discussion on the google group, I am trying to modify the adb_usb.ini file by appending the correspondance device usb vendor id.
But how can I know which usb vendor id should I use? Fortunately, I managed to google a list of vendors for usb drivers here, in which case here, the usb device vendor id is:
vendor TECLAST 0x071b Teclast
I faced the similar problem with Teclast P79HD tablet PC built on Intel CPU. My Windows7 desktop detected the tablet which was connect via USB as an unknown USB device and I could not update its driver. The only program that helped me to revive the tablet was Adb_Run_v.3.78.65 by Vitaly Shipilov. You can download this program anywhere in the Internet. It's free.
You should act in the following way:
Install Adb_Run_v.3.78.65 on your Windows desktop.
Restart your PC.
Click Adb Run icon to start the program, then exit from the program. You should start it to start adb server. After that you will see adb.exe process via the Task Manager.
Go to Setting of your tablet, then Storage -> USB computer connection (additional settings) and check 'Media device (MTP)' in 'Connect as' section. Then connect your tablet to PC via USB cable.
After that your PC will detect the tablet as Media device (MTP). You will see the unit in the Device Manager as Android Phone. Now you can transfer files but you cannot use the tablet in debug mode when USB is connected. To resolve this problem you should act as it is described on the page:
Configuring Your Android* USB Debug Connection
See the second half of this article 'To install the Android USB debug driver on Windows 7, 8 or 10'. The driver which helped in my case was 'Android Composite ADB Interface v.4.0.0.0 [23.05.2014]' by Google, Inc. And I checked 'Camera (PTP)' in 'USB computer connection' instead of 'Media device (MTP)'. After this procedure Android Studio began detecting my tablet right and I was able to use it in debug mode.

Build ADB for an Android Device

I would like to control one android device with another. I have a Samsung Galaxy S III with the USB Host adapter, and would like to control another android phone via ADB. I've looked into this SO post:
build android adb for arm processor
but this isn't necessarily for and Android Host.
Does anyone know how one would go about building ADB for Android? Has it already been done?
Also, would it be "easier" to build ADB against a Linux distro running on the device under emulation? Would control of the device USB port by an emulation app be possible?
Any feedback is much appreciated!
I found a project with this purpose:
p2p-adb.
It has an on-the-device adb executable, so one can 'debug'/control other phones with a phone.

MK802 - Android 4.0 Mini PC - not listed with 'adb devices' command - how to install my app

I recently purchased the MK802; Android 4.0 Mini PC. However, I am unable to install the apps I developed. I have tried using the 'adb devices' command but the device does not appear on the list. I have also downloaded the Andorid 4.0 SDK (the version used in th MK802) on my computer but still no luck. I also made sure to enable 'USB Debugging' and 'Unknown Sources' in the device settings.
I realize I can load my app from an SD card (but I would have to buy one); or that I can download my app onto the device by making it available on a server or the android marketplace but these options seem like too much effort just to install an app.
Any suggestions or recommendations would be greatly appreciated.
Simply adb over USB doesn't work (for now)
The only thing that you can do is: USE WIRELESS ADB!
This widget can help you on enabling it.
Once you got everything up and running do an
adb connect xxx.xxx.xxx.xxx
using as IP the ip address of the MK802. Once connected run an
adb shell
as usual to access the remote shell. Still the system is in heavy development (at least allwinner told so)
EDIT: Using a shorter USB cable could solve the issue!
I managed to connect mine to ADB, even using the included USB cable.
Connect you computer to the dongle's OTG port (it's marked on the dongle).
Go into settings and enabled ADB debugging.
And finally (here's the trick) enable the special Connect to PC setting.
Google for the drivers. Installing the Android SDK will not ensure that your device gets detected.
Connect device
Install drivers downloaded from internet
Disconnect & reconnect
ADB !
In all likelihood, this will solve things for you.

Categories

Resources