failled to access to localhost using volley library [duplicate] - android

What can I do in the Android emulator to connect it to my localhost web server page at http://localhost or http://127.0.0.1?
I've tried it, but the emulator still takes my request like a Google search for localhost or worse it says that it didn't found the page while my web server is normally running.

The localhost refers to the device on which the code is running, in this case the emulator.
If you want to refer to the computer which is running the Android simulator, use the IP address 10.0.2.2 instead.
You can read more from here.

Use 10.0.2.2 for default AVD and 10.0.3.2 for genymotion.

I used 10.0.2.2 successfully on my home machine, but at work, it did not work. After hours of fooling around, I created a new emulator instance using the Android Virtual Device (AVD) manager, and finally the 10.0.2.2 worked.
I don't know what was wrong with the other emulator instance (the platform was the same), but if you find 10.0.2.2 does not work, try creating a new emulator instance.

Try http://10.0.2.2:8080/ where 8080 is your port number. It worked perfectly. If you just try 10.0.2.2 it won't work. You need to add port number to it. Also if Microsoft IIS has been installed try turning off that feature from control panel (if using any windows os) and then try as given above.

You can actually use localhost:8000 to connect to your machine's localhost by running below command each time when you run your emulator (tested on Mac only):
adb reverse tcp:8000 tcp:8000
Just put it to Android Studio terminal.
It basically sets up a reverse proxy in which a http server running on your phone accepts connections on a port and wires them to your computer or vice versa.

according to documentation:
10.0.2.2 - Special alias to your host loopback interface (i.e., 127.0.0.1 on your development machine)
check Emulator Networking for more tricks on emulator networking.

For My Mac OS mountain Lion device :
http://10.0.2.2:8888
Works perfect !

If you using Android Emulator :
You can connect to your Pc localhost by these IPs :
10.0.2.2:{port of your localhost} => if you set your machine port in xamp you must use that port . In my case 10.0.2.2:2080
Also you can use your network adapter IP .In CMD write ipconfig and find your adapter ip address :
If emulator can not connect to this IPs close the emulator an open it by cold boot from AVD Manager :
If you using Genymotion :
You can connect to machine localhost by this IP : 10.0.3.2:{port number}
Or your adapter IP address as I explained above: in my case : 192.168.1.3:2080

I needed to figure out the system host IP address for the emulator "Nox App Player". Here is how I figured out it was 172.17.100.2.
Installed Android Terminal Emulator from the app store
Issue ip link show command to show all network interfaces. Of particular interest was the eth1 interface
Issue ifconfig eth1 command, shows net as 172.17.100.15/255.255.255.0
Begin pinging addresses starting at 172.17.100.1, got a hit on `172.17.100.2'. Not sure if a firewall would interfere but it didn't in my case
Maybe this can help someone else figure it out for other emulators.

Allowing PWA installation
First of all, install the Android debug bridge:
$ sudo apt install adb android-sdk-platform-tools-common
Start your Android emulator as usual, e.g.:
$ ~/Android/Sdk/emulator/emulator -avd Pixel_3a_API_30_x86
Only then, configure a reverse proxy on the bridge of the Android emulator that will forward localhost HTTP requests to the appropriate port (e.g. 8000) of the localhost server running on your host computer and vice versa:
$ adb reverse tcp:8000 tcp:8000
A progressive web application (PWA) being served on localhost:8000
or 127.0.0.1:8000 will be installable and connect to its service-worker.js. Whereas PWA installation is not allowed from IP address 10.0.2.2.
Caveat: adb reverse tcp:8000 tcp:8000 needs to be reissued after each Android emulator evocation.
Hence, a bash script to launch an Android emulator, followed by a reverse proxy, would look like this:
#!/usr/bin/env bash
$HOME/Android/Sdk/emulator/emulator -avd Pixel_3a_API_30_x86 > /dev/null 2>&1
adb reverse tcp:8000 tcp:8000

The accepted answer is correct, but didn't work in my case. I had to create the virtual device with the company VPN-client on the host machine turned off. This is quite understandable as many company networks use adresses starting with 10 (private network range), which could interfere with the special address 10.0.2.2

If you are in windows you can go to simbol system and write ipconfig and check what ip is assigned to your machine.

FOR ANYONE TRYING TO REACH A LOCAL IIS Server (ASP.NET)
For me, the accepted answer was not enough. I had to add a binding for 127.0.0.1 in the applicationhost.config, which was at the root of my ASP.NET solution.

Despite reading all the answers here and elsewhere, I have lost several hours trying to debug this issue, as the address 10.0.2.2 did not work, even in Chrome browser. If the same is happening to you, here is a step-by-step guide to try to debug and hopefully fix your issue.
Check emulator gateway is 10.0.2.2
Inside the emulated Android, go to Settings > WiFi, check if it is connected to AndroidWiFi hotspot (which represents your host computer), and then click on Advanced at the bottom, then check the Gateway address: it should point to 10.0.2.2 . If not, then you have another issue, maybe changing proxy settings can fix your issue, see here how to do that with Android Studio since 2022, as the proxy setting is now hidden away: How to configure proxy in emulators in new versions of Android Studio?
Check if your server is accessible from your host computer
Simply open a web browser and type http://localhost:<port> to see if your local web app is accessible. If not, then you likely have an issue with your local server parameters.
Check if your server is accessible from the emulator
Open Chrome browser, and point it to http://10.0.2.2:<port> (for genymotion, replace with http://10.0.3.2:<port>). If your web app shows up, great, you're done. If not, then test the other steps below to pinpoint the root issue.
Test with another server
In case your web app can be accessed from your host computer, but not inside the emulator, the root cause can be that your local server is restricting access to some interfaces for some reason, likely for security reasons.
To check this, try to use another server, just a simple HTTP server will do, such as http-server with nodejs, or python -m http.server 8000 with Python 3.
Then, try to access this simple server from your emulator's Chrome browser, eg, http://10.0.2.2:8000. If it works, then this confirms that your local server is restricting access to some interfaces. You need to read your local server's documentation to broaden permissions.
For example, in my case, my server was angular-cli (AngularJS), which by default restricts serving only to localhost. To make it work, I had to use ng serve --disable-host-check --host 0.0.0.0 instead of just ng serve, as suggested in this other question. The --host 0.0.0.0 instructs the webserver to serve all interfaces. Similar arguments can be provided to most webservers.
An alternative might be to disable some unused adapters, especially virtual ones such as VPNs.
Your Android app permissions to cleartext
Now, your web app should be accessible from inside the emulator, using Chrome app, with the URL http://10.0.2.2:<port>. The last piece of the puzzle is to add permissions in your Android app to access 10.0.2.2 and especially cleartext if your local webserver is not equipped with a SSL certificate (the most likely scenario for a local development webserver - just check if https://localhost:<port> works or only http://localhost:<port> from the host computer). This will allow your Android app to access your local webserver, just like Chrome does.
Adding specific permissions to access cleartext (ie, http://) from your Android app is necessary since Android 9 (API 28) upwards. There are several ways to configure your Android app to add this permission, see: https://stackoverflow.com/a/50834600/1121352
Conclusion
Accessing the host from the Android emulator can be tricky, but by careful step-by-step debugging, it can be possible to overcome the issue in most cases.
A last alternative, probably faster, is to get a paid subscription to services such as ngrok, but the free version is useless as they necessarily open the webapp in a web browser, outside of your Android app's webview.

I do not know, maybe this topic is already solved, but when I have tried recently do this on Windows machine, I have faced with lot of difficulties.
So my solution was really simple. I have downloaded this soft
http://www.lenzg.net/rinetd/rinetd.html followed their instructions about how to make port forwarding and then successfully my android device connected to make asp.net localhost project and stopped on my breaking point.
my rinetd.conf file:
10.1.1.20 1234 127.0.0.1 1234
10.1.1.20 82 127.0.0.1 82
Where 10.1.1.20 is my localhost ip, 82 and 1234 my ports
Also I have craeted bath file
for easy life yournameofbathfile.bat, put that file inside rinedfolder. My bath file:
rinetd.exe -c rinetd.conf
After starting this soft, start your aps.net server and try to access from android device or any device in your local network(for example Computer ABC starts putty) and you will see that everything works. No need to go to router setting or do any other complicated things.
I hope this will help you. Enjoy.

Another workaround is to get a free domain from no-ip.org and point it to your local ip address.
Then, instead of using http://localhost/yourwebservice you can try http://yourdomain.no-ip.org/yourwebservice

I know this is old, but if you find that 10.0.2.2 is not working as the computer IP, follow these instructions to find it

Related

Unable to connect to an external database [duplicate]

I try to browse localhost on my HTC Magic. I have connected my device with Eclipse via USB. When browsing http://10.0.2.2 I get "Page not available". I remember, some days ago it worked.
But on the emulator I am able to browse localhost
Any ideas?
Easier way to check is in browser of emulator type 10.0.2.2 instead of localhost.
I use my local ip for that i.e. 192.168.0.1 and it works.
to access localhost on emulator: 10.0.2.2. However this may not always work for example if you have something other than a web server such as XMPP server.
assuming that you're on the same wireless network...
find your local ip (should be something 192.168.1.x) - go to the command line and type 'ipconfig' to get this. where x is the assigned local ip of the server machine.
use your local ip for your android device to connect to your localhost.
it worked for me.
If you want to access a server running on your PC from your Android device via your wireless network, first run the command ipconfig on your PC (use run (Windows logo + R), cmd, ipconfig).
Note the IPv4 address: (it should be 192.168.0.x) for some x. Use this as the server IP address, together with the port number, e.g. 192.168.0.7:8080, in your code.
Your Android device will then access the server via your wireless network router.
I needed to see localhost on my android device as well (Samsung S3) as I was developing a Java Web-application.
By far the fastest and easiest way is to go to this link and follow instructions: https://developer.chrome.com/devtools/docs/remote-debugging
* Note: You have to use Google Chrome.*
My summary of the above link:
Connect PC with Phone over USB.
Turn on Phone's "Developer options" from Settings
Go to about:inspect URL in PC's browser
Check "Discover USB Devices" (forward Ports if you are using them in your web-application)
Copy/paste localhost required link to text field in browser and click Open.
Piece of cake
You can get a public URL for your server running on a specific port on localhost.
At my work place I could access the local server by using the local IP address of my machine in the app, as most of the other answers suggest. But at home I wasn't able to do that for some reason. After trying many answers and spending many hours, I came across https://ngrok.com. It is pretty straight forward. Just download it from within the folder do:
ngrok portnumber
( from command prompt in windows)
./ngrok portnumber
(from terminal in linux)
This will give you a public URL for your local server running on that port number on localhost. You can include in your app and debug it using that URL.
You can securely expose a local web server to the internet and capture all traffic for detailed inspection. You can share the URL with your colleague developer also who might be working remotely and can debug the App/Server interaction.
Hope this saves someone's time someday.
Combining a few of the answers above plus one other additional item solved the problem for me.
As mentioned above, turn your firewall off [add a specific rule allowing the incoming connections to the port once you've successfully connected]
Find you IP address via ipconfig as mentioned above
Verify that your webserver is binding to the ip address found above and not just 127.0.0.1. Test this locally by browsing to the ip address and port. E.g. 192.168.1.113:8888. If it's not, find a solution. E.g. https://groups.google.com/forum/?fromgroups=#!topic/google-appengine-java/z4rtqkKO2hg
Now test it out on your Android device. Note that I also turned off my data connection and exclusively used a wifi connection on my Android.
Mac OSX Users
If your phone and laptop are on the same wifi:
Go to System Preferences > Network to obtain your IP address
On your mobile browser, type [your IP address]:3000 to access localhost:3000
e.g. 12.45.123.456:3000
If your localhost is not running on the default HTTP port(which is port 80), you need to specify the port in your url to something that corresponds to the port on which your localhost is running. E.g. If your localhost is running on, say port 85, Your url should be
http://10.0.2.2:85
For the mac user:
I have worked on this problem for one afternoon until I realized the Xampp I used was not the real "Xampp" It was Xampp VM which runs itself based on a Linux virtual machine. That made it not running on localhost, instead, another IP. I installed the real Xampp and run my local server on localhost and then just access it with the IP of my mac.
Hope this will help someone.
If your firewall is on, turn it off and use IPv4 to test your app in the actual device, then test your application.
I had similar issue but I could not resolve it using static ip address or changing firewall settings. I found a useful utility which can be configured in a minute.
We can host our local web server on cloud for free. On exposing it on cloud we get a different URL which we can use instead of localhost and access the webserver from anywhere.
The utility is ngrok https://ngrok.com/download
Steps:
Signup
Download
Extract the file and double click to run it, this will open a command prompt
Type "ngrok.exe http 80" without quotes to host for example XAMPP apache server which runs on port 80.
Copy the new url name generated on the cmd prompt for e.g. if it is like this "fafb42f.ngrok.io"
URL like : http://localhost/php/test.php
Should be modified like this : http://fafb42f.ngrok.io/php/test.php
Now this URL can be accessed from phone.
I use testproxy to do this.
npm install testproxy
testproxy http://10.0.2.2
You then get the url (and QR code) you can access on your mobile device. It even works with virtual machines you can't reach by just entering the IP of your dev machine.
I used ngrok but now it need registration and it also has a connections request limit. Now I'm using LocalTunnel and so far it's much better.

How to connect to kivy-remote-shell?

This seems to be a dumb question, but how do I ssh into the kivy-remote-shell?
I'm trying to use buildozer and seem to be able to get the application built and deployed with the command, buildozer -v android debug deploy run, which ends with the application being pushed, and displayed on my android phone, connected via USB.
However, when I try ssh -p8000 admin#127.0.0.1 from a terminal on the ubuntu machine I pushed the app from I get Connection Refused.
It seems to me that there should be a process on the host (ubuntu) machine in order to proxy the connection, or maybe I just don't see how this works?
Am I missing something simple, or do I need to dig in a debug a bit more?
When the app is running, the GUI will tell you what IP address and port to connect to.
127.0.0.1
This indicates something has gone wrong - 127.0.0.1 is a standard loopback address that simply refers to localhost, i.e. it's trying to ssh into your current computer.
If this is the ip address suggested by kivy-remote-shell then there must be some other problem, though I don't know what - does it work on another device?
Don't know you found the answer or not. But what i have understood is that you are trying to connect android device from Ubuntu. If I am right then (go on reading) you are following wrong steps.
First :- Your Ubuntu does not have ssh server by default so you get this error message.
Second :- You are using 127.0.0.1 address i.e your Ubuntu machine itself.
Method to do this shall be
Give your android machine a static address or if it gets dynamic its OK.
know the IP address of android and then from Ubuntu typessh -p8000 admin#IP_Of_andrid_device and this should solve the issue.

Localhost running on mac.. Can I view it on my Android phone?

Running a ruby on rails project on my mac. I need to test it on my android phone. Is there a way to view my mac localhost on my android phone?
The name "localhost" is just a loopback to your own computer. To access it on your Android, you need to find the computer's IP address.
The most general way of finding this info, which works on both Mac and Linux, is to go into the Terminal and type ifconfig. Look for either "en0" or "en1", and under that entry look for the "inet" listing. It will be something along the lines of "192.168.1.100". When you find that address, that's what you'll want to put in your browser's address bar.
(On a Mac specifically, you can go to the Sharing pane in System Preferences and it'll tell you there.)
Here's a quick to-do to have your localhost available for tests on other devices :
1) identify the IP of your Android : select the Wi-Fi you're connected (the same as the one the Mac is on), you'll have the IP detailed on it). For the example : we suppose your Android IP is : 192.168.0.10
2) open a Shell on your Mac and edit your host :
sudo nano /etc/hosts
3) edit the file as this :
127.0.0.1 192.168.0.10
4) Identify your Mac IP : (as #Chuck perfectly explained)
(in your shell) :
ifconfig
5) Open your favourite webbrowser you use on your phone and connect to your Mac IP (with the port if needed) with directly something like :
http://192.168.x.x:8000/
6) Enjoy your test :)
Notice you can do that for every support connected on your Wi-Fi.
Chunk's answer is correct, assuming your mobile device and your computer are on the same network. However, if you want your localhost server to be visible to the wider Internet (e.g. for testing over 3G, developing webhooks or collaboration with a remote colleague/client), more is needed as local addresses (starting with 10.* or 192.168.*) are not visible to the wider Internet.
The traditional solution to that is port forwarding and dynamic DNS, but lately a few services have popped up which aim to make this process simpler (disclaimer: I am the author of one of them, PageKite).
These services provide you with a public DNS name and software which connect your "localhost" with an in-the-cloud relay server (a.k.a. a reverse proxy). For example, if you are using PageKite, you can run the following command in the terminal:
$ pagekite.py 80 yourname.pagekite.me
... to create a mapping from http://yourname.pagekite.me/ to the web server running on http://localhost:80. While the program is running, your localhost site will be visible to the rest of the Internet. In order to make it private again, you simply turn off the pagekite.py connector program.
For completeness, here are some of the localhost tunneling services I am aware of:
PageKite is Free Software (Python) with a "pay-what-you-want" on-line service. You can create as many long-lived subdomains as you want, a wild-card SSL certificate is included and front-end relays run in multiple geographic locations to provide redundancy and responsiveness.
Localtunnel is a free-of-charge (sponsored by Twilio) Ruby solution which gives connections temporary names. Note that names are recycled so you may see unexpected traffic while the connection is live.
Showoff.io and Tunnlr.com are proprietary paid service comparable to Localtunnel, based on the same basic technology (ssh tunnels).
(Sorry about not linking to the last two, SO spam protection is preventing me from being fair to my competitors. ;-)
Found this great, free tool today - really easy to set up and works like a charm! Versions for Mac OS, Linux and Windows also available.
https://ngrok.com/
(am not associated with it in any way)
This worked for me for accessing rails server with IP over local network:
The firewall has to be turned off.
/etc/hosts should have this entry:
127.0.0.1 192.168.100.12
where 192.168.100.12 is the ip address which can be found by ifconfig command in terminal.
Start rails server with this command:
rails server -b 0.0.0.0 -p 8080
I was able to access my localhost through http://192.168.100.12:8080/
Additionally, if you want to test on Android/iOS device a PWA Apps developed with Angular, you will need to use:
ng serve --host 0.0.0.0 to start up the server CLI.
If you receive "Invalid Host Header", uses:
ng serve --host 0.0.0.0 --disableHostCheck true
after reading this thread (and the suggestions working!) I put together a single guide to solving this issue. This link to that guide that has screenshots for every step and where to look. Or the text is pasted below. Thank you for the help!
First off, both your phone and laptop must be connected to the same WiFi network. If you're using your phones mobile hotspot, it will still work. However, make sure to connect both devices to the same network before moving forward.
Next, collect your phones IP address. To do so, I use the Network Info II app. There is most definitely another way to accomplish this. However, Network Info II works as needed and is document for this tutorials sake.
Now open the terminal on your computer (don't worry about which directory you're within) and run the command sudo nano /etc/hosts/. After entering your system password, you'll see near the top of the terminal a string of numbers with the word localhost following. Localhost is in fact just an alias for your computer's own server address so that when you go to localhost in a browser it simply routes the http request to your local machine. In order to tie your phone into this loop, enter its IP address right between the string of numbers and Localhost.
To save this, hit control + X and then Y when prompted to save. After that, the enter key will bring you back to the standard command line.
Open a second tab in the terminal and launch a local server. I've only tested this using a simple python server, which can be run by running in the terminal python -m SimpleHTTPServer 8000. However, I'm assuming that you can launch any local server you like, being that all you'll need to reference is the port number. If you do use the simple python server, that port number is 8000.
Run ifconfig in the terminal. This will bring up a slew of information, to which you should scroll about halfway down. What you are looking for is a string of numbers that follow after an inet and before netmask within either the en0: or en1: key.
Done! On your Android, open up a browser and visit the inet number, followed by a colon (:) and the port number.
Although one answer has been accepted but this worked for me:
Make sure both your computer and android device are on same network.
get your computer's ip address. (in case of mac type ifconfig inside terminal and look for en0/en1 -> inet it should be something like 19*.16*.1.4.)
Open your mobile settings and go to network-> long press your wifi network-> modify network -> scroll down to advanced options -> chose proxy manual and in proxy hostname type your address i.e. 19*.16*.1.4 inside port enter your port. and save it.
search for what is my ip in google chrome, and get your ip, lets say it is 1**.1**.15*.2**
try accessing 1**.1**.15*.2**:port/ from your mobile device.
It is as simple as this.
MacOS Catalina 10.15.4
Go to Settings -> Security and Privacy.
Select Firewall tab and unlock the settings using your laptop password:
Select Firewall Options... and in the dialog uncheck the box for Block all incoming connections and hit OK.
Open Terminal and type ifconfig. Look for the en0. In the section find the address sitting near inet - this is the address of your laptop in a local network.
en0: flags0=<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 0
...
inet 192.168.0.123 netmask 0xffffff00 broadcast 192.168.0.255
...
Use the IP address + the port (in case you are using localhost:4200 for development), otherwise omit the port:
http://<IP address found in en0 -> inet>:<port if needed>
Profit!
If you run your localhost with php the solution was replacing localhost with the Macs IP
php -S 192.168.x.x:8080
instead of
php -S localhost:8080
For MacOs, open up System Preferences > Network.
you should see the message " and has the IP address: my-ip-address"
That will be your IP Address, then in the browser navigate to http://my-ip-address/port-number. Remember not to put an "s" in the http.
As mentioned in other answers, url has to consist of the IP address of computer and not localhost. If that isn't working, before trying anything else, check if the port is correctly mentioned along with IP address when making an api call in the Android app. That is, you should be making an api call to a url which is of the format: http://192.168.X.X:80/api/..
For using localhost on Android you should use your local ip address when connecting to it. First check your local ip address of your computer. Then follow along:
In addition to the good accepted answer, if you need to use localhost via your local ip address follow this steps:
Add your local ip address into httpd.conf (/etc/apache2/httpd.conf) as below:
(Change the port according to server you are using)
Listen 12.34.56.78:80
Listen: Allows you to bind Apache to specific IP addresses and/or ports, instead of the default.
Save, close and restart apache.

How can I forward my localhost IP-Address to an Android Emulator?

I know it is possible to forward a port from my develop machine to an Android emulator, but how is this done?
I've found the solution on the android-developers site, but I couldn't see how they've meant their instructions...
Anybody got some clear instructions on this? My develop machine is running Windows.
To forward a port from your local machine to an Android Emulator, you need to have Telnet enabled. This is done through the Control Panel -> Programs and Features -> Turn Windows features on or off -> scroll down to Telnet Client. Then select it & press Ok. Now from your command prompt (with the Emulator running) you type telnet localhost "EmulatorPortNumber". The "EmulatorPortNumber" can be found in the titlebar of the Emulator, in my case it was 5554.
You will now see something similar to this:
Android Console: type 'help' for a list of commands
OK
Here, you want to type with as little as possible typo's, as when you apply the backspace, it will corrupt your command and not accept it. The command you have to use here is redir. This will let you choose from 3 subcommands:
list list current directions
add add new redirection
del remove existing redirection
The one you need now is add. But you can't use it just like that. Typing redir add will give you the following line:
KO: bad redirection format, try (tcp|udp):hostport:guestport
This means that you have to specify what kind of port you want to forward (TCP or UDP port), which port on the local machine you want to forward (hostport) & which port you want to set on the Emulator (guestport).
So, using a command like this:
redir add udp:1337:12345
forwards the UDP port 1337 on the local machine to port 12345 on the Emulator. Be cautious about deleting redirections, as they might crash your Emulator. You can also simply close the Emulator to remove any redirections. It's easier & safer...
You access your computer's localhost as 10.0.2.2 from emulator. more details here
You can use the adb forward command to set up arbitrary port forwarding — forwarding of requests on a specific host port to a different port on an emulator/device instance. Here's how you would set up forwarding of host port 6100 to emulator/device port 7100:
adb forward tcp:6100 tcp:7100
For example run NanoHTTPD web server on the AVD and then execute this command on the computer:
adb forward tcp:8080 tcp:8080
Open the browser on the computer and navigate the below address:
localhost:8080
http://developer.android.com/tools/help/adb.html#forwardports
Using latest version of Android Emulator (in Android Studio 2021.1) it works in a very simple way
on my dev machine I start a service on http://localhost:8080
on my Chrome (dev machine) I go to: chrome://inspect/#devices
the port forward starts automatically
on my Android Emulator I can reach the website on the dev machine just navigating to: http://localhost:8080

Accessing intranet in Android emulator

I'm trying to test an intranet site in the Android emulator, but I can't seem to get the emulator to access our intranet. For example, the site I'm trying to access is at http://compass/messages, but trying that page in the browser gives me a Google search result page instead of the intranet site.
I can access the INTERNET with the emulator, but not the INTRANET. I can access the intranet from the host machine, and from the iPhone simulator on the same machine.
I'm assuming there's some sort of weird command line thing I need to do, but I'm pretty clueless...any ideas?
After a tremendous amount of searching with no answer, I was able to access my local dev server by substituting the domain with the ip address. For example, instead of:
http://compass/messages
use this (with your server's IP address)
http://172.33.22.1/messages
It works in the Android emulator browser, and also from a WebView in the app in the emulator. I don't know why this works, but it does for me. Hope it helps someone else.
I was having the same problem and I wasn't been able to find any solution anywhere. What I finally did (after playing around with port forwarding) was to use ssh to create a tunnel to the remote machine:
ssh -L 5555:localhost:5555 10.0.1.14
This should allow you to connect to the local machine's IP address in the emulator (10.0.2.2) and reach the other machine in your network (on the specified port).
If anyone has a better solution for accessing the local network from the android emulator I'd love to hear it.
Intranet site may require proxy.
You can set the proxy in Settings
I have solved this problem by following steps:
adb shell
set setprop net.dns 10.10.20.19(your pc's ip)
restart your emulator.

Categories

Resources