In the stock Android emulator, 10.0.2.2 always maps to the host. This makes it handy for baking into web service tests on the device. Is there any equivalent host name or address for the Visual Studio Emulator for Android or a way to create one?
Hyper-V creates a "Internal Ethernet Port Windows Phone Emulator Internal Switch" with address 169.254.80.80, but the emulator can't access it.
there is no such builtin address I believe, but you can do something similar:
create internal LAN switch in hyper-v and link it to some of your network cards (wifi or ethernet) via internet connection sharing (ICS).
in this case host adapter attached to this internal switch will get fixed address (192.168.137.1) and some kind of dhcp server serving 192.168.137.0/24 subnet.
attach this switch to android image in hyper-v and emulator will get address 192.168.137.abc, will be able to connect to host on 192.168.137.1 and have access to internet at the same time
Related
I am developing android app using Google Cloud Messaging. I am using external server xampp and testing it on external mobile(no emulator as it is slow). This is basically chatting app. I am facing problem in getting connection.
I know i need to use http://10.0.2.2:8080 ip for testing if I am using emulator in my client code.
and somehow I need to use router ip http://192.168.x.xx:8080 if I want to test it on external device. I need some guidance as how to configure things to make it possible.
Thanks
Deepak
You can do it with Google Chrome port forwarding as mentioned below
Step 1:
Enter chrome://inspect/#devices as mentioned below in your desktop chrome window
Chrome window will also show the device name, model number, and the ip address.
Chrome Remote Debugging Devices Detection
Step 2:
Add the port in the ports to forward it and to be accessible on the device as shown below.
Click on the button Port Forwarding and check the Discover USB devices.
You will get a small modal as below, where you can enter your localhost address and access it via app on the external devices easily.
Then, after adding the address, check the Enable Port Forwarding.
You are all set done for accessing it on the external device.
Chrome Port Forwarding Settings for Remote Debugging on Android
Chrome on your Android external device also should be open simultaneously to view the output.
Step 3:
Then use the url opened up in the device in the App to directly test on the External Device
Desktop(Development Machine)
Android(External Device)
Note:
1.The device should be connected with a USB cable to the development
computer which has forwarded the port, else the connection is lost.
2.This mode is not available in Incognito Mode in Chrome
If its external but still local (not on the internet), then both have to be on the same network.
make sure you can access the app its self using the ip address.
Try to enter it into your browser, if you can access the app, then proceed to using it as the ip in android.
you can use tools like Connectify(windows), ap-hotspot(linux) to setup a network ip. which your phone can connect to.
I tried to connect to a localhost on my windows PC from Android devices but it doesn't work at all.
I host it using ISS Express (installed with VS2013)
I tried http://10.0.2.2:59087 and my ip http://192.168.43.83:59087
I connected them using an AP from my Android and from the router
I also disabled windows firewall
All this configurations but nothing is changed
What is the problem?!!!
you HAVE to be in the same network for this to work, that's all, you don't have to go through all that trouble, if you are in the same network, then you can access your ip easily just make sure your windows side server (eg: localhost:8080) is active and accessible
I am trying to implement an Android application in Windows 7 using Eclipse. I am trying to connect the Android simulator to the local test server in my company, but for some reason, it cannot connect to the test server.
If there is any settings or configurations for this, please let me know.
I have tried to do the same from a MAC machine using iPhone emulator and I am facing the same problem. How would this emulator connect to the local servers in my company as currently it all goes to live servers? What configurations are required to be done on the simulators, and how?
If I try to connect to the test server from normal Windows machine browser, I am able to successfully connect to it through the web browser; but when I try to do the same from the Android emulator browser, it cannot connect to it.
The emulator points to the live network and not the local network in my company. This is strange and I know that I need to do some settings for it, but I am not sure where these settings are done and how.
If accessing local computer:
http://localhost:8080/MyLocalServer.html // URL to use in computer browser
http://10.0.2.2:8080/MyLocalServere.html // URL to use in emulator browser
Also try using a local IP to connect to any local servers. Do not use host names.
Dont:
http://mylocalserver.org/
Do:
http://192.168.1.125:portnumber
You have to set up IP-based hosts instead of name-based.
Emulator its - VM. This use virtual network connection. I think you need before chech this connection (this connection may bee stay as NAT, Breedge, Native IP adress, Proxy).
Since you do not work iPhone emulator, most likely you, IP adress virtual network connectionб which uses Emulator, does not match the address area of the local network, and routing occurs
This may help you...
Taken from the android docs:
If you need to refer to your host computer's localhost, such as when you want the emulator client to contact a server running on the same host, use the alias 10.0.2.2 to refer to the host computer's loopback interface. From the emulator's perspective, localhost (127.0.0.1) refers to its own loopback interface.
http://developer.android.com/guide/faq/commontasks.html#localhostalias
I want to debug my android application, I connect the android device to my PC using the USB cable. In my application there is a button to connect with localhost, ip for localhost is 10.0.2.2 and the port is 8080, I have read that when debugging on mobile, the ip 10.0.2.2 is the localhost for android device and not for my PC, so what changes should I make to the ip instead of 10.0.2.2? or do I have to make another change?
In this case my android device is sony ericsson xperia arc s.
Google has added support in Chrome 29 and higher to use reverse port forwarding to access a website hosted on your local development machine through the USB cable on Chrome for Android. Setup instructions can be found at the following URL:
Android Remote Debugging - Reverse Port Forwarding
Tools for Web Developers - Access Local Servers
As of desktop Chrome 30 Reverse Port Forwarding is no longer an experimental feature in Chrome. It can be accessed by typing about:inspect in the address bar of your PC, and by clicking the "Enable port forwarding" check box and clicking the "Configure port forwarding" button located to the top right of the window.
Once that is done, connect your mobile device via USB. Open Chrome on your mobile device to localhost:8000 (or whichever port you have configured on your local server).
The Reverse Port Forwarding functionality will make sure that your Android device now sees your PC's localhost.
As 10.0.2.2 is your system (pc)'s local host address (from emulator only). Actually android doesn't recognized localhost in url. so 10.0.2.2 is for that meant. Also for android device loopback address is 127.0.0.1.
Your url with 10.0.2.2 is correct. Also you can use Static IP of your system.
Just check for
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
in your application's manifest file.
EDIT:
Here you are using port 8080 so, try with adb command on your host machine.
adb forward tcp:8080 tcp:8080
Also please elaborate on this line "i want to debugger my application on my mobile".
Note:
If you are going to test on real device use your Network IP of system (PC).
For that you need to make some changes in your xampp server... Assign 1 static IP address to your system and then you need to put your xampp server in online mode. after that you can use that ip address in your android application instead of 10.0.2.2. Works fine for me as i am using my localhost with my android application.
You can share your Mac's Internet connection over Wi-Fi. Then your Android app can connect to a Servlet running on the Mac with HTTP over Wi-Fi. The steps are:
Run System Preference on Mac
Goto "Sharing" tab
Turn on "Internet Sharing"
Select "Ethernet" in the "Share your connection from" combo
Select "Wi-Fi" in the "To Computers Using" list box
Use "Wi-Fi Options..." button to configure Wi-Fi security. Now your Mac is a Wi-Fi server, and it is sharing its Ethernet Internet connection.
Configure your Android device's Wi-Fi to connect to your Mac (in Settings command)
On your Mac, goto the Network tab in System Preferences, and select Wi-Fi in list to find out the IP address of your Mac on the Wi-Fi network (for me it was 169.254.66.223)
In your Android App you can now connect to the Servlet in your Mac with "http://169.254.66.223:8080/YourServer/YourServlet"
I think you have two options
The first one is using 10.0.2.3 when you use your real android device.it works for me.
Your Second opt is creating hotspot from your pc and connect your android device to the hotspot.
Find the ip address using cmd type "ipconfig" replace localhost with the ip address.
Thanks.
I am trying to deploy and test my application on an android device which is then connected to my laptop with a usb-cable. Now, how can I target a webapp deployed on my laptop ?
knowing that my wifi is down and that I don't have the right to change router configuration to do some IP port forwarding tricks (in case you would like to suggest me to use the mobile network e.g 3G, go on internet and get back in via our router external IP address ==> which is also a little bit heavy given what we want to do here)
According to the android documentation, "the emulator" can use the ip address 10.0.2.2 to access the hosting computer but there is nothing for devices...
thanks in advance guys,