4

I'm using laravel valet to serve an API on a Mac. How can you access it from an Android emulator

YKalinde
  • 146
  • 8

2 Answers2

0
  1. Edit the /etc/hosts file on your Android Emulator following the instructions in this SO answer.
  2. 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.

Cameron Wilby
  • 1,867
  • 1
  • 21
  • 35
-1

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.

Xvolks
  • 1,987
  • 1
  • 19
  • 29