Android无法访问本地服务器(localhost)的解决方案
16lz
2021-01-23
最近在Android开发中,发现无法访问localhost(127.0.0.1)。
Google之,得解:
Issue 133: localhost/127.0.0.1 not supported
原因分析:
Android模拟器把它自己作为了localhost!
换言之:使用localhost(127.0.0.1)访问的都是模拟器自己而非本地!
解决方案:
使用Android为本地机器定义的别名(alias):10.0.2.2 来替代localhost(127.0.0.1)即可。
Google之,得解:
Issue 133: localhost/127.0.0.1 not supported
原因分析:
Android模拟器把它自己作为了localhost!
换言之:使用localhost(127.0.0.1)访问的都是模拟器自己而非本地!
解决方案:
使用Android为本地机器定义的别名(alias):10.0.2.2 来替代localhost(127.0.0.1)即可。
更多相关文章
- Android创建AVD模拟器
- Android模拟器虚拟串口实现串口通信
- 用emulator启动模拟器
- PC安卓模拟器PANIC: Could not open:C:\Documents and Settings
- Android的组成,AS连接mumu模拟器
- Android之如何安装(卸载)apk文件到模拟器