In Android emulator I encounter "Connection is lost.Host is Unresolved" error while communicating with server (creating websocket) if URL string is used. instead if IP address and port number is used it works fine.
I have configured it in host file of my ubuntu powered pc. It pings and all from the desktop.
any ideas?
Since the emulator skips the systems hosts file, change the etc/hosts file of the emulator, follow this link
http://eclecticdreams.com/blog/getting-a-hosts-file-onto-an-android-emulator
This is one of the common problems appear in android's native emulator. To resolve this, you need to restart the emulator. Or debug your application on a real device.
As an alternate, I would also like to draw your attention towards Genymotion which offers very stable, reliable and fast android emulators ranging from different device profiles and API versions.
Related
I have an ASP.NET/Azure application running on http://localhost:4617. I would like to debug a REST call made from an Android emulator. Related SO threads seem to indicate that you should use 10.0.2.2. I've tried several variations like http://10.0.2.2:4617, but none seem to work. Any other suggestions?
If I do ping localhost on my machine, it returns Reply from ::1: time<1ms which seems to have something to do with an ipV6 address, but I'm not sure how this is related.
If the local host is running on your desktop than that is the problem.
When you type http://10.0.2.2 it tries to connect to the Android emulator local host.
What you need to do is find your computer IP address (you can use google for it). Then once you have it type that into your android emulator browser and it should work
I was able to figure this out. If you're running an Azure server-emulator, then you need to run Visual Studio with administrator privileges. If you don't, then it will not bind correctly to the local host.
I am using VS 2013 to connect with the new VS2015 Android Emulator. This seems to work now and I can debug, set breakpoints etc which is all fine. (Now, I would use VS2015 but it won't deploy properly -never mind).
I am also developing the server app on my machine and using Fiddler as an http debug aid.. not an uncommon situation I am sure.
The server is running (also under debug in another instance of VS 2013) using IIS Express and I have added bindings to the applicationhost.config so the IISExpress server is visible on my LAN from other PC's and I've checked it is visible.
Try as I might I can not seem to get the Emulator to send the http requests back to my computer.
My javascript uses a servicebase to hold the url:
var serviceBase = 'http://192.168.2.4:64963/'; //'http://169.254.220.177:64963/'; //'http://10.0.2.2:64963/'; //'http://localhost:64963/';
The commented ones show the ones I have tried. None of these works.. the first is the IP of my machine on the LAN, the rest are various ones I have picked up here or the Android dev site.. I have also tried:
http://mymachinename:64963
Because I am bringing both web AND API services from this URL I have also tried a chrome browser on my real android phone (over wifi on my LAN) and this can't get to my dev machine either (where my other pc's can). So I get that it probably can't resolve the names? But really not sure where to go next? I wondered about the Hosts file on my PC but not sure if I can/should set an IP address as a host name? .. any pointers? Thanks, Brett
169.254.80.80 is the localhost loopback.
By going to Additional Tools in the VS emulator for Android (click the >> button on the right hand side) and selecting the Network tab, you will get all the information about the network connectivity.
For the localhost loopback, use the address listed under the Desktop Adapter #2. Desktop Adapter #1 should work as well, which is the IP address of your machine.
I am answering this because I have seen a lot of comments/questions about this topic and need to include some bits that it is hard to fit in the comments.. and I have solved it.
First the solution.. was to delete/replace the vsemu.vhd and vsemu.sdcard.vhd for the emulator with safe copies. This was because in my efforts to fix the problem I assume I had changed some setting in the emulator phone data. Sadly I am not sure what.
However, and this checklist may be useful to someone, before this I was led to it by the fact that because I had web services as well as API from my server URL I was able to test webpage access. This worked on pcs but failed on wifi connected android devices on my network with pc names.. as mentioned in my original question. But it wouldn't work with a numeric IP address either.
I had already added the numeric IP to the applicationhosts.config file of IISExpress, but what I hadn't done, because I thought its on the machine its referring to, was execute the
netsh http add urlacl url=http://192.168.2.1:94693/ user=everyone
command to let it all through.
Once I had done this, I was able to connect using the IP address from a phone, and this led me to discover that the Emulator had obviously got some form of problem. Replacing the VHD's fixed this and I am now communicating.
In case anyone else has this issue using the following IP's worked for me:
IP of the machine
169.254.80.80
However, do remember that VS Android emulator is running in a Hyper-v VM,
So I had to punch a hole in my firewall to allow for my application port to be reached by the emulator.
If your using Web API with visual studio 2015 and VS Android emulator this link helped me out a lot
Use 10.0.2.2, This is the loopback from emulator to your host machine.
See link:
http://developer.android.com/tools/devices/emulator.html
I was having the same issue, but none of the above answers were useful for me.
My BackEnd is a PHP SlimFramework Rest Api.
I decided to change the IP in the auto start of the Slim (was localhost:7888), I tried this: php -S 192.168.43.20:7888, and everything was working fine after I configure the calls to that ip.
I hope this may help someone...
In generic the IP you must consider is the IP of the network you are using/allocated to run the android emulator.
Very raw/rude method of finding it is by going to settings (gear symbol on right panel of emulator, not the one inside) and look for ip address. . Or by opening the ADB Logging window and it's on the top left corner.
Now in command prompt type ipconfig and match the first 3 numbers of IP and that's the network your localhost loopback.
Because in many cases we will have more than one ethernets or virtualbox host only networks are running.
Happy Coding!!
I am trying to develop an wifi peer to peer application in android(4.+).
The problem here is how to test it.
I tried to run that application in android emulator. there was no option to configure wifi in the settings menu, i also tired to enable wifi using the dev tools application form the emulator but it didn't work, And through all my googling over 3 days and i found that Android emulator is not supported the Wifi.
So i opted for androidx86 4.0eeepc using virtual box and tired to add devices both wifi and bluetooth (my app uses both bluetooth and wifi) but only bluetooth device got added and it did not work. But my virtual box detected the wifi and bluetooth devices. I just couldnt get them work with the virtual machine.
I tried everything like manually adding the addresses using terminal emulator app in androidx86 and used netcfg through the android commandline but neither of them worked.
Please suggest and guide me on the correct path to run these kind of applications that use wifi and bluetooth in android.
Thanks in advance.
First, be sure you enabled WiFi Direct in the Android settings for the two virtualbox instances:
Settings --> Wireless & Networks --> More... --> Wi-Fi direct
It has been stated as working once that hurdle was overcome, and I'm sure many have experienced the same...just be sure to enable wifi direct
I would have tried exactly what you've already tried by naturally moving from the emulator to the androidx86 project. Although unreliable, I'd recommend looking at and finagling this, if you haven't yet seen it: Android: Simulate WiFi in the emulator? and How to disable/enable network, switch to Wifi in Android emulator? most likely wouldn't have full out success but may be enough to let you know that it works or would work.
As far as testing WiFi-Direct/WiFiP2P without you yourself having a device/s, I would recommend:
Trying out some of the fiddling as mentioned above. And read through tons of logs.
You could always crowd source it to friends, or release an apk on a forum for a small group of testers.
Of course, both of those options are not ideal, seamless, or fast. So, I'd definitely hope you get VirtualBox VMs of AndroidX86 4.0 running as it should once you check that setting and pair up the WiFi APs :-)
A near future solution:
This might be something to look into in near future.
Real devices are hosted by Samsung and screens are streamed to your PC.
http://developer.samsung.com/remoteTestLab.do
According to an email responded by samsung, which I sent to them earlier.
They only have 2 devices (Galaxy Nexus) running on Android v4.0 at the moment.
Unfortunately they are not physically close to each other. (One in Korea, One in Poland)
But they are planning to upgrade existing Galaxy S2 to v4.0.
Because recently Samsung have released v4.0 upgrade for S2.
Once they done that, there will be plenty of v4.0 phones.
And you can ask them which 2 phones are physically close so you can test Wifi Direct.
--------------------------- EDIT ---------------------------------
There are plenty of ICS devices there now, which you can test P2P.
Check with them which 2 are physically near to each other.
Per the docs:
Each instance of the emulator runs behind a virtual router/firewall
service that isolates it from your development machine's network
interfaces and settings and from the internet.
You have to use Network Redirection, as described in the Developer Docs. In essence, you forward specific ports using ADB. Therefore you cannot test certain things like broadcast messages.
I have tried doing what you are trying to do, and-- while I won't say it is impossible (anything is possible in computing with enough time, money, and persistence)-- I wasted a lot of time on it. You cannot treat the Android emulator as a normal network peer-to-peer device. As far as I have been able to find, it is a fork of QEMU, and that is just how the QEMU emulator is implemented.
QEMU itself does support TUN/TAP bridging, but I was never able to get it working with the Android emulator. If you want to go that route, you may want to investigate running Android in the QEMU emulator, rather than in the SDK's emulator (I see you are already trying a similar approach with VirtualBox).
Unfortunately the best way to test a peer-to-peer networking program in Android is with physical devices at this time-- unless your app can suffice with the port forwarding method.
See Also: Issue 26:Emulated Androids should be able to communicate via TCP, and Google
(Repeating here my answer elsewhere.)
In theory, linux (the kernel underlying android) has mac80211_hwsim driver, which simulates WiFi. It can be used to set up several WiFi devices (an acces point, and another WiFi device, and so on), which would make up a WiFi network.
It's useful for testing WiFi programs under linux. Possibly, even under user-mode linux or other isolated virtual "boxes" with linux.
In theory, this driver could be used for tests in the android systems where you don't have a real WiFi device (or don't want to use it), and also in some kind of android emulators. Perhaps, one can manage to use this driver in android-x86, or--for testing--in android-x86 run in VirtualBox.
Currently I'm working on a project that demands using Android and tcpdump.
A short description of what I do:
I want sniff packets using android. I have built an android application which does this using by "tcpdump".
Basically the application initiate tcpdump, which dumps the captured packet in a file (in the sdcard). Then I process the captured packets just by opening the file.
The problem :
When the wifi is in managed mode, everything works fine. But, when I put the wifi device in "ad-hoc" the wireless device stops working.
I'm using "Samsung Captivated S" (SGH - I897), and in order support "overhearing" (promiscuous mode) and ad-hoc I installed the latest "Cyanogen 7" rom ( cm_galaxysmtd_full-126.zip, from: http://download.cyanogenmod.com/?type=nightly&device=galaxysmtd)
I don't know how to solve this and I would really need your help. I suspect
that "wpa_supplicat" is to blame for that, but most probably I wrong.
Thanks in advance,
Ps: I should also mention that I start an adhoc network using my laptop. Then two android devices join the adhoc network. The android devices (SGH-I897) join the network without a problem. All the devices can ping each other.
only solution for this is described here.
http://www.44actions.com/?p=273
I was trying to connect an ad-hoc network from Nexus S. However I realized the unpleasant news that Android does not support ad-hoc networking. After a quite amount of research, I found a work around which is:
a) Root the device and
b) Copy wpa_supplicant to system bin.
I'm totally unsure how much successful that would be. Being fairly apprehensive to further this method, I returned back to research and, unfortunately, ended up in vain.
Has anyone dealt this before? Is there any fix for ad-hoc networking in Android?
While Adnroid (at least 2.3) does not have interface for setting up Ad-hoc or Master modes, sometimes (like on my SE Xperia X10) you can just use iwconfig (need to be copied to device manually) and set it to Ad-hoc mode.
I use it sometimes, having scripts that ad-hoc mode on and off (there is even dhcp server configured on the device)
Well, I am facing the problem too. and was googling around and could not find anything worth sharing with you. Just a work around, Use ConnectifyME to create an AP in your PC and then you can use that AP (can say virtual AP) to share internet on your android device.
Hope this helps you.
There is a GUI program called Virtual router that is open source program and could be used to create WiFi, it uses virtual Wi-Fi feature in Windows 7.
For more description have a look at my post:
http://algorithmsea.blogspot.in/2012/12/ad-hoc-network-from-android-devices-i.html
adhoc isn't supported in android os but typing 2 lines DOS commands should solve the problem.
I tested this and it works.. type these 2 lines on DOS COMMAND PROMPT
netsh wlan set hostednetwork mode=allow ssid=NAME key=PASSWORD
netsh wlan start hostednetwork
I found this here : For Android users:Internet via adhoc is working without any app! : http://androiditnow.blogspot.com/2012/09/for-android-usersinternet-via-adhoc-is.html#.UXV0bUqlrGI