I wanted to know if it is possible the comunication between two Android Emulators started on two different machines networked.
For example
- Emulator A run on machine M1
- Emulator B run on machine M2
Can A and B exchange messages?
If yes, what ip address do I use?
Thank you very much
Deborah
You might know this already. As of android-sdk-tools_r7 it should at least be possible to connect two emulators to each other. Whether is works between physical machines is not something I know. It might be possible to set up masquerading between the two hosts for this specific broadcast.
From the android commit
Enable interconnection of emulators
This patch adds a -shared-net-id option to the emulator which
joins the emulator in a shared network.
If the option is given the emulator is started with an additional
network interface bound to a multicast socket. This multicast socket
emulates a network hub, interconnecting emulators.
If the -shared-net-id option is not given, nothing changes.
To connect two emulators, use the -shared-net-id <number> command line option when starting the emulator. They will then directly share everything sent to or read from ip 10.1.2.<number> on the emulator.
Another approach would be to enable port forwarding between the emulators using adb, and then set up masquerading for those ports on the networked machines.
I'm not really sure that either of these solutions match the use case that you're asking after. If not, adding more details to the original question might help. :)
Disclaimer: I have not tried the first approach, and the second I've only used to make sure that an emulator could bypass a nasty corporate firewall and HTTP proxy so that we could test the android browser. The principle should be sound though.
Update:
Nope, I played around with it a whole lot and found no nice solutions. I am not good enough at iptables to set up a valid tunnel that way that works for the server end.
Regards,
Mikael
An emulator normally has outbound access to the development machine's LAN or internet connection, so the problem is on the inbound side.
You can use an emulator or ADB port forward to send traffic into the emulator, but possibly only locally originating traffic on the development machine's loopback interface, and not external traffic. If that is indeed the case, the simplest thing would probably be to write or configure a port forwarder that listens on the development machine's external interface and forwards to the port that is forwarded into the emulator.
Related
So, let me start off by saying that I am 'relatively' familiar and comfortable with making Android apps and using both LogCat and DDMS to debug.
That being said, I'm encountering more of a logistical issue than anything else right now - I am making a locative app, where the GPS is fuelling and controlling other methods in my Activity, and after a while, it is crashing.
Now, because it is locative, I am walking around to test it, in order to receive different GPS locations. Because of this, I am not connected to my computer at the time that it crashes, so have no way (that I know of) to read the stack trace, etc.
In my particular instance, I am navigating through a series of activities, and finally reach the penultimate screen in my app, and while I am running the application in my studio, it runs indefinitely without issue. It is only when I take the device outside that it crashes...
I am wondering if anyone has any tips or tricks with this issue - I'm sure give the prevalence of locative apps, it must have come up, but I cant seem to find the right search terms. It could be as simple as saving the LogCat to file, and/or the stackTrace, but I'm not sure that's the answer...
Thanks in advance.
If I got you right, this is what you are looking for:
https://play.google.com/store/apps/details?id=org.jtb.alogcat&hl=de
Edit: Also there are many more apps like this. You can just browse around in Google Play Store
You can debug the app without rooting your android, unlike the other responses. start off by plugging the android into your computer, then run adb devices to make sure the device is there. Then, run tcpip 5555 to change the android to tcp mode, which will allow debugging over wifi. Disconnect the android from the computer, and connect to it by typing adb 192.168.x.xxx, replacing the x's with your android's IP address. It should connect with no issues, as long as port 5555 is open, and both the android and your computer is on the same wifi.
Simple: Wireless ADB
One of the reason that I choose to run CyanogenMod on my testing devices is that it is a stripped down version of Android that has some additional developer tools, one of those being the ability to access the wireless portion of the ADB system.
As you are probably unaware, you are able to establish an ADB connection to your device over WiFi, however, if running a stock ROM, this requires root access, as it can be potentially harmful to your device, as Wireless ADB will work even over your cellular network, meaning that you could potentially receive apps from other insert carrier here's devices.
If you wish to run WirelessADB, here is a Play Store app that will help you to enable the feature on your device. Requires ROOT
It is as simple as connecting your device to your local WiFi network, (same one the development computer is connected to), enable Wireless ADB, and then running the following command on your computer:
adb connect 192.168.1.101
Replacing 192.168.1.101 with the IP address of your android device.
By establishing this connection, you can run everything just as you would if the device was plugged in via USB Cable.
I recommend ACRA (Application Crash Reports for Android ). It allows you to send crash reports to a number of different destinations. See https://github.com/ACRA/acra/wiki/BasicSetup
My company requires VPN to connect to our dev systems and for the first time I'm trying to work on an android app from home. Turns out the emulator doesn't want to use the VPN interface so even though I have connectivity to our dev systems on my VPN-connected laptop the emulator that's running on it does not.
I have thought of 3 solutions to this:
run a VPN client on the emulator, but I was hoping for a simpler solution than that
setting up a proxy server on my local machine
forwarding a port on my local machine
2 and 3 can probably work, but I'd still like to know if there is an easy way to get the emulator to use the VPN interface without a workaround.
I'm running OS X 10.7 and I've already tried adjusting the interface priority order with network>>set service order.
I suppose I can dust off the old dell and try it there, but I would expect the same results.
First start your vpn connection and then restart the emulator, now the emulator should use the host vpn connection.
it's mostly because of the DNS issue, according to the android doc:
At startup, the emulator reads the list of DNS servers that your system is currently using. It then stores the IP addresses of up to four servers on this list and sets up aliases to them on the emulated addresses 10.0.2.3, 10.0.2.4, 10.0.2.5 and 10.0.2.6 as needed.
I encountered this issue and tried something on dns settings but I could not solve it. As #machado said in the comment section below you should boot the emulator via "Cold Boot Now" option. I hope this helps.
What I do on my mac is just make sure 'send all traffic over vpn' is checked.
You'll find this setting after you click advanced while having your vpn connection selected in network preferences.
Works well for my situation, but may not depending on the type of VPN you're connecting to.
I had the same issue and solved it by connecting to cisco vpn after the android emulator has started and connected to the internet.
Works for me in windows 7
I setup a vpn connection on Windows. Then I started the emulator. The emulator and everything on my pc started to use that vpn connection.
hy again!
I'm trying to connect two emulators running as server and client on the same PC.The thing is that one of them is inside a virtual machine.What addresses should I use for each of the emulators in order to connect between them?
I'm using a TCP based connection!
The first emulator is running on Windows 7
The second one inside the Vmware is on Xp
The IP of my PC inside the network is 192.168.71.1
Really gratefull if u answer.Thx!!
I imagine you'd want to use the localhost address (127.0.0.1). Set the server up to listen and once it is up and running have the client connect and you should be good to go. (Make sure the port you use matches, obviously.)
http://en.wikipedia.org/wiki/Localhost
A few more details would help:
What is the IP address of the VM?
Is it using NAT, bridged networking, or what?
Do you really need to run the 2nd emulator inside a VM - this complicates networking.
UPDATE: Multiple emulators on 1 machine (no VM)
You can launch another emulator from the command-line, using /emulator -avd . You'll need to create a second AVD for this to work. I use Linux, so can't give the exact details for Windows.
UPDATE: Communication between main machine and VM with android emulator
I believe the emulator only listens on 127.0.0.1 for server sockets, so remote machines can't connect in - this is certainly the case for the debug sockets it uses. However, you can set up port forwarding using a similar method discussed in Remote debugging with Android emulator
It's good that you're using bridged networking, as NAT would stop the VM getting inbound connections, so the emulator would have no hope.
UPDATE #2: Port forwarding
You can set up port forwarding between sockets on the local machine and on the emulator, using adb forward. It might also be worth looking at Communication between Android Emulators, there appears to be an undocumented emulator switch -shared-net-id that could help.
Hope this helps
Phil Lello
I'm developing client/server software for Android.
While connected to the phone via USB debugging, I'd like to access the webserver I'm running on my developement PC - using the USB connection.
Is that possible and if so, how ?
I stumbled upon the answer after a night sleep.
Enabling USB tethering on my phone (N1, 2.2.1) gives it and the host computer an IP address. The phone can communicate with my web server running on my developement machine!
(Chris, the rumors are right)
Just make sure your web server is listening on that IP address. For apache, use the line
Listen 80
or
Listen x.x.x.x:80
(x.x.x.x being address of your android tunnel)
The easiest way to do it is via wireless. If you don't have wireless, I'd say bite the bullet and get it, it's going to be a necessity for testing anyway :)
Typically the USB only supports connections from the development machine to the phone (via adb port forwards) and not the other way around. Of course once a connection is created data can move bidirectionally. One could use this to build a tunneling proxy web proxy (one connection in from the development machine to a daemon running on the phone, outbound connections from the phone then tunnel through this)
I have heard rumors though that what you want to do - often called reverse tethering - may be supported in some more recent devices.
Kevin's wifi suggestion may be the simplest with a real device.
On the other hand, unlike typical phones, the android emulator can directly access the development machine's loopback interface at an alias address given in the documentation.
I need to test my android app 24h a day and I have 3 ubuntu boxes to do it.
I would like to connect my development system (MOTODEV Studio 1.3) to a Remote Device.
The interface asks me for an IP address and port for the machine to connect to.
But it doesn't connect. I found that the adb sever on the remote machine doesn't seem to listen to external ports, only internal loopback, making machine-to-machine connections impossible.
Is this true? If so, why there is a section on Device to connect to Android Remote Device on MOTODEV Studio?
I've found an explanation and a workaround in this post (http://rxwen.blogspot.com/2009/11/adb-for-remote-connections.html) but it seems complicated and the post's links don't work, so I'm confused whether there is a solution to do that.
It seems so simple..... I can't believe there is not a way.
The Remote device feature of MOTODEV Studio is intended for TCP/IP connections to a remote phone. It requires a lot of manual intervention at this point to get things working and it's an area where we're definitely in need of better documentation.
I don't have the full workflow in front of me, but the steps you need go like this...
Connect phone to remote host.
Using adb shell on remote host, set the phone to connect over TCP/IP rather than USB. You'll need to find the IP address of the phone manually. If you're using a Motorola phone and the Motorola drivers, it's probably 192.168.16.x
Set up port forwarding from the remote host to the phone for the debug ports (probably 5554 or 5555).
From the local host, set up the address of the remote host in the IP field.
When choosing "Run as" or "Debug As" from the local host, you need to choose the remote device as your target.
We intend to make this workflow more automated in the future, but for now you have to do this manually. It's my observation that remote debugging of embedded systems is still slow and prone to problems with latency and line quality, regardless of whether we're talking about phones or reference boards.
Good luck.