Access localhost on laravel valet from Android emulator - android

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.

Related

Access docker localhost API from Android Emulator

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?

Access localhost, Mac Android Studio Emulator

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 ;)

There is any configuration for this tools eclipse or wamp or android sdk to connect my mobile phone to wampserver

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

Connection error - connection refused

I am developing an Android app, using Mobile ADF in JDeveloper 11.
I used weblogic server with SOAP service. When I test the webservice, its working fine, but I am getting this error after deployment on Android emulator -
"cannot connect to 127.0.0.1 on port 7101: java.net.ConnectionException:connection refused".
use 10.0.2.2 instead of 127.0.0.1
and for SOAP
use port 8080 instead of 7701
Use 10.0.2.2 instead of 127.0.0.1
10.0.2.2 Special alias to your host loopback interface (i.e., 127.0.0.1 on your development machine)
Reference: Emulator Networking
Use this address: 10.0.2.2 or the real IP address if you have one.
See also the Docs

Can't connect android emulator to look at local sites and services

I'm trying to use an Android emulator to use services running on my local machine. I have a site running under IIS which in my host file looks like this:
127.0.0.1 www.local.company.co.uk
I have several sites running under Apache Tomcat. My host file for Tomcat related sites:
127.0.0.1 internal.localhost.company.com # port:8090
127.0.0.2 external.localhost.company.com # port:8081
127.0.0.3 auth.ws.localhost.company.com # port:8082
127.0.0.8 mysite.localhost.company.com # port:8086
What I have tried so far (in the following steps):
adb pull /etc/hosts
Edit Android host file:
127.0.0.1 localhost
10.0.2.2 myefc.localhost.efinancialcareers.com
adb remount
adb push hosts /etc/hosts
Then I try to visit myefc.localhost.efinancialcareers.com in the browser and am told webpage not found. I’d at least expect it to go to www.local.company.co.uk.
What I would ideally like is to be able to go to any site on my local machine which are specified in the above host file examples.
I am on Windows 7 and using Tomcat 6. The emulator I am using is nexus one.
You need to use the IP address of your server. If you reference localhost from the device it will try to make a connection to itself through the loopback IP address 127.0.0.1.

Categories

Resources