Connect Eclipse to Android emulator on a different machine - android

Can't seem to find the following information although I'm pretty sure this should be possible:
I'm running an Android emulator on a machine A. I'm developing on another machine B in which I'm using Eclipse.
Now when I switch to the DDMS perspective in Eclipse, I want the emulator from machine A to show up in the devices tab.
The reason is, that the emulator is quite slow and it looks like running development and emulator on different machines might be a solution.
Since the emulator runs on a specific port, I'm pretty sure I just need to figure out how to tell eclipse where to look for emulators.
Thanks for any tips

You can tell adb to connect to a device listening on an IP address and TCP port. That device should then show up in eclipse. So the debug machine is easy.
The emulator machine may be harder. The emulator is listening for TCP connection on a local port. IIRC it has been established that there's no command line switch to make it listen on an external interface, though double check that. So you might have to modify and recompile the emulator, or use some kind of port-forwarder on the hosting machine. ssh might handle that for you though I'm sure there are other tools without the encryption overhead if that's not needed.

In the meantime, I found a very nice solution to the problem. I installed android-x86 (http://www.android-x86.org) in a virtual machine.
On the host, you then use the following commands to restart adb and connect to the vm:
adb kill-server
adb connect <VM-IP>:5555
Replace VM-IP with the actual IP of your virtual machine. If you're on a private network, the easiest way is to configure vm network as bridged so the VM gets its own IP address from the dhcp server. Should also work with Host-Only networks though as described here.
If all went well, you should see the android VM in the Eclipse debugger just like normal emulators.

Eclipse doesn't attach to the emulator directly.
The adb background process controls communication with the emulator (as well as real devices).
Adb listens on TCP port 5037 for incoming commands.
I haven't tried your scenario but this should get you started.

I did it with the following steps.
Start the emulator on the remote machine
Start a port forwarding application on the remote machine (forwarded tcp:5557 to localhost:5555)
Start adb with connect remote_machine_IP:5557 on my development machine
Start eclipse
Eclipse will find adb and list the device.

Follow these steps to connect your VM to eclipse IDE:
First run ICS from your VM and open up android command prompt. (Navigate to applications and run Terminal Emulator)
Type "netcfg" in terminal to find out IP of your vm
Then go to cmd(windows command prompt) and move to "platform-tool" folder in your android installation path(in my case cd C:\android-sdk-windows\platform-tools)
Then type "adb connect your ip" command (adb connect 190.156.10.122)
Now you can debug your android application in vm without pain. Try this and this

After struggling with this, I found this video that explained how to get emulator running on my mac while running my dev environment in a VM.
http://youtu.be/CacpPleWsZM

Related

How to develop Create React Native App without a network - using USB only

I would like to develop an app in Create React Native App in the environment where connecting from the Android device to the development server is not possible.
I have installed Android development tools on my laptop and the device is connected to it via USB. When I run npm run android everything starts correctly as it should, Expo is opened in the device but then it ends with an errors:
Could not load exp://192.168.128.150:19000. Can't connect to internet. Please try again
Does this mean that I cannot use Create React Native app without network between the mobile device and the working computer ?
It might not be the best solution, but it worked for me and i hope it'll be enough to help you out!
I was having the same problem and did the following:
Connected the device to the PC through the USB Port
Verified if it was authorized using adb devices
Disconnected the PC/Laptop from the internet
Ran npm run android with the device connected
Waited for the Javascript Bundle to be built
Reconnected the PC to the network after the application was running on the device
After that i could normally develop through the USB! Hope i've been of help!
I've struggled with that for last couple of days with my development environment on the virtualized Ubuntu 18.04. I have 2 interfaces on the guest machine (host-only as ens33, and bridge as ens39).
First of all I've installed react-native-cli to work on.
The steps I do to work only with USB cable (e.g. in VPN network with no chance to connect the device):
Bring all all interfaces listed in etc/etc/interfaces down. , e.g. sudo ifdown ens33. In my case only host-only is listed there so I can still work with the bridge interface.
Connect the device through USB port.
Run adb usb and then adb devices.
Just in case run adb reverse tcp:8081 tcp:8081.
Run react-native start --reset-cache in one terminal. If you have an error with ENPOSC while starting Metro Bundler on 8081 port then follow the instructions here: Node.JS Error: ENOSPC.
In the second terminal run react-native run-android. If all things went good you should see "exp://127.0.0.1:19000" on the screen just under QR code and running app on the device.

Cannot Connect to Chromebook via ADB for Debugging

I'm trying to connect to my Acer Chromebook over IP to load and debug apps. I've followed the instructions here:
http://opensourceforgeeks.blogspot.com/2016/12/debug-android-apps-on-chromebook-using.html
These are the same instructions you can find on Google's site. I'm in developer mode, can side-load apks, etc. From that standpoint everything is working fine. However I continue to be unable to connect using the adb connect command. It times out. I'm out of ideas. I've tried to connect to the Chromebook from several computers and none work. I can ping the ip address and get packets back so I know that much is correct.
My only other option is to purchase a different system and try that, but I'd rather not do that.
Very strange, I had this issue with port 22, so then I tried it without a port and it worked, it used port 5555.
Problem : Not able to make ADB connection on Chromebook ( DEV MODE)
Problem analysis: The problem can occur for the following issues
1. Chromebook get updated on new version
2. dev feature of SSH on chromebook get deleted by
Solution : 1. Press Ctrl-Alt-T to bring up ChromeOS terminal, and type shell to get bash.
crosh> shell chronos#localhost / $
chronos#localhost / $ sudo /usr/libexec/debugd/helpers/dev_features_ssh (//enable secure shell and configure firewall properly.)
It worked for me
In my case (host machine Win 8.1 x64) the problem was:
1. USB3 port. After I switched cable to USB2 I saw Chromebook in windows' devices list as unrecognized device.
2. Manually install "Android ADB interface" device' driver.
After that I was able to use adb commands from host machine.

Connect guest OS (ubuntu) to genymotion on host machine

I have an Ubuntu VM running on VirtualBox and an Android emulator running through Genymotion (which also uses VirtualBox), so I thought I could easily connect one VM to the other, right? Turns out it isn't so simple. I added a bridged adapter to the Ubuntu VM, restarted the ADB server and then ran adb connect -emulatorIP- This allows me to see the device, but the problem is that adb insists that the device is offline, when it quite clearly isn't. So I'd like to ask for help with this issue.
So actually all you have to do is pretend that you're trying to connect to a remote device. On the host machine run
adb tcpip <port>
which will enable that port for remote connection. Then run in the VM
adb connect <deviceip>:<port>
to connect to the genymotion device.
For further reference: https://developer.android.com/studio/command-line/adb.html#wireless

From eclipse of host machine build and run androidx86(in virtualbox) of second machine

I have two computers , second computer is used as second monitor with the help of synergy
iam interested in android programming.
As AVDs are very slow,i use AndroVM as a way to to run my programs from eclipse
my question is i want to click build and run in eclipse of first machine, instead of running in AndroVM on my host machine i want to run it on AndroVM installed on second machine for seamless access with help of synergy.
is there a way to set up in virtual box? iam a noob,detailed explanations would help.
You can achiev this via tcp/ip.
install X86 Android with this network config
give Android a IP
Press:
ALT + F1
Type:
netcfg eth0 dhcp
setprop net.dns1 8.8.8.8
connect adb with the virtual mashine
./adb connect [ip from last step]
Check out my detailed tutorial I wrote a few months ago.
http://standroid.blogspot.de/2012/06/android-4-x86-in-virtualbox.html

Debug device connected by USB to VirtualBox's host, from Android-Studio inside VM

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 .

Categories

Resources