Android Studio’s Android Virtual Device (AVD) is a powerful tool for emulating Android devices. However, it can be a bit confusing when it comes to network settings.
Typically, 127.0.0.1
(or localhost
) refers to itself, i.e., the current machine. However, in AVD, 127.0.0.1
refers to the emulator itself. In other words, the emulator sees itself as localhost
.
Therefore, if you want to access the localhost on the development machine from the emulator, use 10.0.2.2
. In other words, the URL to access the localhost on the development machine is http://10.0.2.2/になります
.