我可以在模拟器中连接到localhost,但不能在真实设备上连接

I really made research about this issue but nothing works for me. I am using WampServer and have a php webservice.

I wrote an app on Android Studio. I have a login.php at localhost. On android emulator I use 10.0.2.2:8080/login.php and everything works perfect. But on real device,it is not working. I tried

127.0.0.1:8080 (localhost)
192.168.2.1:8080 (default gateway)
192.168.2.60:8080 (IPv4 adress).

Nothing is working, what should I do? I hope somebody knows the answer

Thank you in advance

I did suffer from the same problem from past 2 days, but I ultimately found the fix:
1) Change the entry in httpd.conf:

#onlineoffline tag – don’t remove
Require local

to

#onlineoffline tag – don’t remove
Require all granted

Source: https://www.youtube.com/watch?v=XbBGYm14xY4

2) Change the entry in httpd-vhosts.conf:

<Directory “c:/wamp64/www/”>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>

to

<Directory “c:/wamp64/www/”>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>

Source: https://www.youtube.com/watch?v=WzD_J9vSF0E

You should connect to local IP of your PC (you can check with ipconfig/ifconfig).

I guess that is 192.168.2.60:8080 you wrote. Then make sure you are on same network and that port 8080 on your PC is open.