Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/205.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将emulator连接到laravel服务器本地主机:8000_Android_Laravel_Networking_Android Emulator - Fatal编程技术网

Android 如何将emulator连接到laravel服务器本地主机:8000

Android 如何将emulator连接到laravel服务器本地主机:8000,android,laravel,networking,android-emulator,Android,Laravel,Networking,Android Emulator,当我的android应用程序以10.0.0.2:8080连接到wampserver中的项目时,我可以连接到localhost:8080,但我使用的是laravel,我的web服务位于localhost:8000中。我想从emulator连接到IP 10.0.0.2:8000的laravel服务器中的web服务,但无法连接到它 10000毫秒后无法连接到/10.0.2.2(端口8000)。 我尝试了localhost:8000和其他一些IP,哪个IP用于连接到laravel服务器 有点晚了,但你的

当我的android应用程序以10.0.0.2:8080连接到wampserver中的项目时,我可以连接到localhost:8080,但我使用的是laravel,我的web服务位于localhost:8000中。我想从emulator连接到IP 10.0.0.2:8000的laravel服务器中的web服务,但无法连接到它

10000毫秒后无法连接到/10.0.2.2(端口8000)。 我尝试了localhost:8000和其他一些IP,哪个IP用于连接到laravel服务器


有点晚了,但你的问题与你的路线有关。首先,假设您在windows上,请转到主机文件并将IP:10.0.2.2映射到127.0.0.1

像这样:

127.0.0.1    10.0.2.2
然后,如果已配置虚拟主机,请将IP 10.0.2.2映射到httpd vhosts.conf中的项目目录

像这样:

<VirtualHost *:80>
    DocumentRoot "C:/www/example/"
    ServerName 10.0.0.2
    ServerAlias 10.0.0.2
</VirtualHost>

DocumentRoot“C:/www/example/”
服务器名10.0.0.2
ServerAlias 10.0.0.2

有点晚,但您的问题与您的路线有关。首先,假设您在windows上,请转到主机文件并将IP:10.0.2.2映射到127.0.0.1

像这样:

127.0.0.1    10.0.2.2
然后,如果已配置虚拟主机,请将IP 10.0.2.2映射到httpd vhosts.conf中的项目目录

像这样:

<VirtualHost *:80>
    DocumentRoot "C:/www/example/"
    ServerName 10.0.0.2
    ServerAlias 10.0.0.2
</VirtualHost>

DocumentRoot“C:/www/example/”
服务器名10.0.0.2
ServerAlias 10.0.0.2

如果您在远程服务器上解决了这个问题,但在本地计算机上运行起来很困难

1。以以下方式启动服务器:

 php artisan serve --host 0.0.0.0
现在它可以接受来自emulator的请求

2.在android应用程序中,分配给主url:

"http://192.168.0.106:8000/api"

如果您使用远程服务器解决了这一问题,但在本地计算机上很难运行,则可以从命令提示符窗口中的ipconfig命令获取url

1。以以下方式启动服务器:

 php artisan serve --host 0.0.0.0
现在它可以接受来自emulator的请求

2.在android应用程序中,分配给主url:

"http://192.168.0.106:8000/api"

您可以从命令提示符窗口中的ipconfig命令中获取url,谢谢,但有一点应该提到。您应该运行命令
php artisan serve--host=x
。x是通过在windows中运行命令
ipconfig
和在linux中运行
ifconfig
获得的ip。在emulator中,您应该打开
x:8000
。无论如何,它起了部分作用。它只加载
favicon.ico
app.js
@USER3718908谢谢你,但有一点应该提到。您应该运行命令
php artisan serve--host=x
。x是通过在windows中运行命令
ipconfig
和在linux中运行
ifconfig
获得的ip。在emulator中,您应该打开
x:8000
。无论如何,它起了部分作用。它只加载
favicon.ico
app.js
@用户3718908