Backstory: I'm developing an app on a Chromebook using the Linux (Beta) feature whereby I have VS Code, GIT and everything else installed. Plugging my phone into the Chromebook pops up a "Connect to Linux" dialog which then makes it accessible via adb running in the Linux VM. From there I can install and run my test application as part of a build script. Parallel to this I have Android enabled on the Chromebook and set it into developer mode which lets me access adb via CROSH. From this shell I can install and run APK's directly on the Chromebook itself through its Android emulation layer.
What I would like to do (if it's even possible) is to access the Chromebook's Android layer via adb in the local Linux (Beta) VM. Thus I would be able to run my build script to run, install and launch on the Chromebook Android layer itself.
My idea: the Chromebook would need to provide an emulated USB device to the Linux VM or I could somehow setup the Chromebook Android stuff so that I could connect over a local port (TCP/IP) with adb.
Thoughts, insight, resources?
The answer is to run adb connect arc and then the Chromebook shows up in the ADB devices list!
Thanks to Morrison Chang who provided the link to https://chromeos.dev/ which led me to https://chromeos.dev/en/android-environment/deploying-apps#deploy-with-terminal .
It seems that if your Chromebook is in developer mode then the convenient UI "Develop Android apps" is not available.
I am trying to execute automatic tests using robotframework + appium + Jenkins.
My biggest problem is to set up the necessary infrastructure.
I have a Windows VM (slave) with 4GB RAM but the emulator took more than 30 minutes to getting started.
I do not have a physical server to connect the device by USB.
How can I set this up in a efficiently way?
Is it possible to set up an Android device directly as slave (connected to master via wi-fi) and install robotframework in the device?
How many RAM/CPU I need If I need to get a better VM where I can handle the emulator efficiently?
I appreciate suggestion. Thanks.
It is very unlikely you manage to configure your Android phone as a Jenkins slave. It's just too many libraries that you would need to build on your own so they run natively on Android. You would need to have the Jenkins slave, Appium, Robot Framework and your app running in the same phone, which isn't as powerful as any regular computer.
However, if your device is rooted, you can try something like WiFi ADB to at least get the lowest level layer to your phone available over the air. There is also a manual setup with no software available at How can I connect to Android with ADB over TCP?.
If rooting is not your option, but you can connect the device through USB just once (which I assume you can't do because probably you're using a cloud host like Azure and that's why you can't physically access the machine), do it and run adb tcip 5555 (or your desired port). This will allow you to desconnect the device and use it over WiFi with the trusted computer connected through USB (until you kill the ADB server!).
After any of both procedures, configure your project as usual and set the udid capability to the IP of your phone in the network (try to configure a static IP address) and its port, for example 192.168.0.24:5555. Before running the tests, you have to run adb connect 192.168.0.24:5555 so adb is aware of the device and Appium can find it.
You still will have some trouble getting the VM and the phone in the same network, but for that issue there are plenty of options available like configuring a VPN.
I am doing an Android app by connecting to a Virtual machine in Azure cloud by connecting to it via RDP(Remote Desktop Protocol). One week ago I was doing my development in local machine but my machine crashed so I started working in cloud. Back then, working with my local machine I had these privileges
1)Using of 'use Host GPU' option while creating an Android Virtual Device
2) Use of HAXM or intel virtualization technology/Hypr-v as I had access to my BIOS to set that up.
And I have a Google nexus 7 device and I used to work with it when ever emulators cannot do the job.(Like taking a picture for real)
Remote VM, I have no access to BIOS in Azure so I cannot make use of HAXM to speed up my emulator and of course I cannot use HOST GPU option while creating the AVD. It takes a long time to fire up the emulator and to deploy again and again. (My VM is a Azure D4 with 8 cores and 28 gigs of RAM)
I need to find out a way to forward my adb port to local machine so I can deploy apk into local device but yet developing from the cloud.
I went through following links but did not have anything working for 4 days now. I am stuck with my development totally until I get a new machine. Can someone please help on debugging locally
Usb data cable comunication in Android
adb forward remote port to local machine
https://bitbucket.org/chabernac/adbportforward/wiki/Home
Especially if any of you have configured the third link (chabernac's
adbportforward) please help me by stating how to do it.
Both vm and mobile device should be on the same net to work flawlessly
Just plug your device via usb on localmachine and in terminal type
adb tcpip 5555 (or the port you want to use)
unplug your phone, test if you connect to the device
adb connect <device ip>
then
adb devices
it should show the device you're connected to
Now type this to disconnect from the device
adb disconnect
go to %HOMEPATH%\.android and copy the rsa keys:
adbkey
2adbkey.pub
Go on remote machine and paste those two files to the same path.
Repeat step 2 and 3 to check if the device is connected
This works on devices 4.2+
This is the article which helped me a lot
http://www.cleansoft.lv/debugging-android-applications-remotely/
I am trying to get mono for android (aka monodroid) working within a windows 7 virtual machine on virtualbox but I am having issues with the adb connection to my phone. When I run "adb devices" to list the devices present it show up no problem, but when I attempt to run an "adb install", logcat, or push it hangs. Currently there is a bug in virtualbox which applies to this but I was hoping someone more knowledgeable than myself would have a workaround.
https://www.virtualbox.org/ticket/6620
Of coarse non of this would be an issue if Xamarin released a linux port of their product or if I got familiar with Java, but I suppose those are slightly different issues.
Brian, one workaround you might consider is to make your VM host an ADB host as well. Then you can just connect your VM client to it over TCP / IP. Here's the general idea for that setup:
Install the Android SDK on the host machine. You should only require the platform-tools package which includes adb.
Don't allow your VM client to take ownership of the Android device, so disable any VirtualBox USB filter rules you have and it also wouldn't hurt to then detach and reattach the device.
From your VM client, run adb kill-server. Make it a tskill adb for certainty. If you have any running instances of Eclipse, you'll want to shut those down first because it'll actually launch adb in the background. Don't skip this step.
From the host, execute adb devices. If all goes well (and it should), you'll see your device listed. It should look something like this (note the port number and sorry for the mangling):
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
015d2994ed200409 device
At this point, your host should have an ADB server running at port 5037. You can check this from the VM client by running telnet 10.0.2.2 5037, where 10.0.2.2 is the default IP for VirtualBox hosts and 5037 is the default ADB port noted above.
Now you must either forward the ports from your host to your VM client, or otherwise connect ADB directly to your host IP:port. If you're like me, you'll find the ADBHOST and ANDROID_ADB_SERVER_PORT variables to be poorly documented and easy to screw up. For this reason, consider simple port fowarding over ssh (maybe via Cygwin) like so from the VM client:
autossh -nNL5037:localhost:5037 -oExitOnForwardFailure=yes 10.0.2.2
Finally, run adb devices from your VM client. If you see "daemon not running," it means your port fowarding is screwed up. Otherwise you should see your device and be able to logcat all day. One noteworthy point is that you won't have an adb daemon running on your VM client, except for when you're actually using the debug bridge, of course.
I've used a similar mechanism for debugging devices over the network that are connected to remote machines and it worked well.
Not sure what has changed in VirtualBox since the question was posted, but selecting the usb device from VirtualBox menu Devices -> USB -> DeviceName worked seamlessly. I am working on VirtualBox 5.1.2 r108956.
I was also having trouble with ADB running over VM. I had a Windows 10 host and an Ubuntu 14.04 client. The autossh method did not work for me. I found an easier solution from another StackOverflow question. It requires that both your PC and your device are on the same WiFi network.
On your VM client run the following: adb tcpip 5555
The device will disconnect from the VM because ADB is now in TCP
mode instead of USB.
For the next part you need the IP address of
your device. To find it, simply run adb shell ip -f inet addr show wlan0
Now you can connect to your device. On your VM client, run:
adb connect <Device IP>:5555
From here all my adb shell, logcat, and monkey sessions ran without interruption!
I'm posting this here for people with a setup similar to mine:
Host OS: OSX (10.15.4 Catalina)
Client OS: Windows 10 Enterprise (v1903 build 18362.752)
VirtualBox v6.1.4
Android Studio v3.6.2
To allow Android Studio in client OS (Windows) to connect to an Android phone (using adb) via USB:
Update to latest version of VirtualBox (currently 6.1.4)
Install VirtualBox Extension Pack from here
With the VM powered down, go to Settings > Ports > USB and make sure the USB 3.0 (xHCI) Controller is enabled, then click "OK"
From the host OS (i.e. OSX) open up a terminal and start adb and confirm that the phone is connected by running adb devices
Start up the VM, and from the VirtualBox menu select Devices > USB > [YOUR PHONE] to connect your host OS USB port to the VM
Open up a terminal on the client OS (Windows) and run adb devices to confirm that the adb server is running and can find your phone. You might need to add the Android platform tools to your PATH (mine was at C:\Users\Username\AppData\Local\Android\Sdk\platform-tools). This step might be optional--I suspect that Android Studio might start up adb on its own.
Start up Android Studio in the client OS (Windows) and go to File > Settings > Appearance and Behavior > System Settings > Android SDK > SDK Tools and make sure that the Google USB Driver is installed (see screenshot here)
After I did these things, Android Studio was able to detect my phone and run/debug apps using that device.
Hope this helps!
I had the same problem and it made me search for about 2 hours.I tried several approaches including all above solutions but none of them worked
My situation
My host was archlinux and the guest was windows 8.1 I was running flash builder in windows but the usb debugging wouldn't work and my connected device was nexus 5 so i followed these steps
Enable USB controller from virtualbox menu Machine-->settings-->usb enable usb controller and enable USB 2.0 (EHCI) controller then add your device(click on + button on right side) then start your virtual machine
Now you should download the latest google usb drivers from here and extract it
Go to control panel device manager right click on your device go to driver tab and click on Update driver there should be two option one search automaticly ... and another browse my computer choose the second one and give the extracted file path(check the Included subfolders option) after this your device should be recognized by windows and there will be a message in your android device for allowing access to your device
In my case i should copy the drivers to flashbuilder android drivers path too but maybe for your situation this isn't necessary
I had same problem with VirtualBox 5.0.14 and solution provided by Stephen Niedzielski didn't work for me. If someone is still interested can try this solution.
My environment is:
Host OS: Mac OS 10.11
Guest OS in VirtualBox: Ubuntu 14.04
Device: Galaxy S5 running Cyanomodgen 12.1
Start a wifi hotspot in host OS and connect there the android device, or connect both in a router. In virtualbox set network mode for guest OS to 'Bridged Adapter' and then select name of Wifi adapter. In that way host OS and android device are in same network.
Then, in android device activate 'Developer mode' and enable 'ADB over network', provided from Cyanomodgen. (For devices with original version of android, google how to use ADV over network if possible)
In host OS run 'adb kill-server' and make sure no instance of ADB is running. Then run command 'adb connect 192.168.2.12', ip of android device.
Congrats :) Now you are are able to use ADB with android device to take logcat or pull and push files.
Install the Android SDK on the host machine. You should only require the platform-tools package which includes adb.
Don't allow your VM client to take ownership of the Android device, so disable any VirtualBox USB filter rules you have and it also
wouldn't hurt to then detach and reattach the device.
From your VM client, run adb kill-server. Make it a tskill adb for certainty. If you have any running instances of Eclipse, you'll
want to shut those down first because it'll actually launch adb in
the background. Don't skip this step.
From the host, execute adb devices. If all goes well (and it should), you'll see your device listed. It should look something like
this (note the port number and sorry for the mangling):
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
015d2994ed200409 device
At this point, your host should have an ADB server running at port
5037. You can check this from the VM client by running telnet 10.0.2.2 5037, where 10.0.2.2 is the default IP for VirtualBox hosts and 5037 is the default ADB port noted above.
(https://stackoverflow.com/a/12557836/16902966)
and in the virtual machine (Windows):
set ADB_SERVER_SOCKET=tcp:10.0.2.2:5037
Connected device(s): ...\platform-tools>adb.exe devices .
I have two questions about Linux Android.
In the documentation it says:
"Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device."
And apparently there is a way to send a command to serial port (USB) from ADB (Android).
So, I need to send commands (like AT commands) from android device to usb device (printer)
1) The ADB will be present on a real device with android?, which version?
2) is there another alternative?
Thanks in advance
And apparently there is a way to send a command to serial port (USB) from ADB (Android).
Not that I am aware of.
The ADB will be present on a real device with android?
adb is a program that is part of the Android SDK. It runs on your development machine. It does not run on the emulator. It does not run on the device.
is there another alternative?
Use the USB APIs and the Open Accessory Development Kit, perhaps.