I'm running a local http server on port 3000 and i'd like to access that server using an Android emulator. I've tried the following in the browser:
localhost:3000 //
127.0.0.1:3000 // of course I gave my local ip a try
10.0.3.2:3000 // I think this is a genymotion ip?
10.0.2.2:3000 // The most prevailing suggestion was to use this ip
With each of these i'm given this error:
Interestingly when accessing the same in chrome on my desktop:
localhost:3000 // works
127.0.0.1:3000 // doesn't work
Perhaps this is connected? I'm not sure why 127.0.0.1:3000 doesn't work, but that might be a different hurdle altogether.
My /etc/hosts file:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
I've already tried reloading (& disabling) my firewall and proxies.
The emulator i'm using is:
Mac, Android Studio 1.5.1
Emulator : Nexus 5 - API 21, Android 5.0 x86
Use following Service
https://ngrok.com/
It will give you a tunnel to localhost and give you a URL which you can use from anywhere in the world ;)
Related
In my current Android Emulator with API 26 I'm trying to access with it's browser to a localhost subdomain set in the android emulator hosts file with no success.
I successfully managed to root my emulator and modify it's /etc/hosts file (pushing a local file and with busybox mini vi implementation). Some of the successful tests that I made in the browser and with the ping command from adb shell are as follows (where 192.168.0.10 is my current assigned host ip):
192.168.0.10 source
192.168.0.10 source.api
192.168.0.10 source.api.local
10.0.2.2 source
10.0.2.2 source.api
10.0.2.2 source.api.local
but with localhosts subdomains mappings I can only ping the domain from adb shell with success. The browser displays an ERR_CONNECTION_REFUSED error in the next host mappings:
10.0.2.2 something.localhost
10.0.2.2 something.something.localhost
Any ideas on why this is happening?
EDIT:
The current problem only happens in my macOS 10.14, I couldn't reproduce the problem in Ubuntu 18.04.
The problem is with the Multicast DNS (mDNS) implementation of macOS, when using the top-level domain .local
Bonjour... "will automatically resolve the private IP addresses of link-local Macintosh computers running MacOS and mobile devices running iOS if .local is appended to their hostnames."
RFC 6762 Appendix G recomends the following private namespaces instead of .local|.localhost to avoid conflicts.
.intranet.
.internal.
.private.
.corp.
.home.
.lan.
I'm attempting to test my local dockerised API against a staging version of my app.
I don't have access to the repository to build the App myself so I'm relying on changing the IP address within the emulator to point at my local machine and that's where I'm failing.
I've set it to 10.0.2.2 as per the emulator documentation, and when I ping the staging url from the ADB shell (ping mystagingsite.com) it responds data from 10.0.2.2 . But from within the app, the response is always empty. I've tried 127.0.0.1 which obviously won't work, and I've tried my network IP address.
Is what I'm trying to do possible? If it is, what is the right IP address to put in the /etc/hosts file of the emulator and how do I find that address?
I'm using laravel valet to serve an API on a Mac. How can you access it from an Android emulator
As the Android Emulator is different computer than your Mac, you should use the IP address of the Mac (or its name if it is resolved on your network) instead of localhost.
For example if your Mac has IP address 192.168.1.10, then use this address.
Edit the /etc/hosts file on your Android Emulator following the instructions in this SO answer.
Add the following to this file:
myapp.test 10.0.2.2
This will route requests made to myapp.test to 10.0.2.2, which is a static IP address that an AVD uses instead of localhost to access the host.
New to Android, I have .Net webservices residing in my PC. when my Android application calls the webservice from emulator with IP address, it runs perfectly.
But running the same code in mobile does not work (mobile is connected to PC using USB cable). It shows server timeout error. Both phone and PC are on the same network.
I am unable to run - adb pull /data/anr/traces.txt. It says unrecognized command. I had Android studio installed but unable to find adb file.
So installed Android Sdk again: C:\Program Files\android-sdk-windows\tools - it says that adb file has moved to platform-tools. I tried various ways but no luck.
Any suggestions are welcome. Many thanks in advance.
If your web service is not hosted, you need to use localhost or 127.0.0.1 in your mobile app's URL IP address. Make sure they are in the same network
here is any configuration for this tools eclipse or wamp or android sdk to connect my mobile phone to wampserver?
i look this exemple in this site blow i just copy and paste the code in eclipse but the problem is how i can import and export data from my phone to database and Conversely ?
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
If I've understood correctly, you're running a wamp server locally on your computer and you'd like to access that server from your application. The general approach is similar to connecting to any other server, but you'd have to find the right IP-address to connect to. Try this:
First, make sure your server is up and running.
Second, access the server on your computer using one of two addresses:
If you're testing your app on the emulator (AVD), use this: 10.0.2.2, which translates to the localhost-address on your computer.
If you're testing your app on an actual device, you'd have to find your computer's IP-address. On linux, open a terminal and execute the command ifconfig. In windows, I believe it's ipconfig. Use the address listed under wlan0 -> inet addr.
Remember to append the port number your server is running on.
EDIT
Example, given port number is 80:
Emulator: 10.0.2.2:80
Device: 192.168.X.X:80