我试图在Android中运行我的电容器应用程序,通过Android Studio运行-应用程序打开并说:
"Webpage not available - the webpage at "http://localhost:8100" could not be loaded because of ERR_CONNECTION_REFUSED"
很明显,我不能从我的安卓设备(只能从有线连接的电脑)导航到http://localhost:8100
来访问我的应用程序,所以我想知道它应该如何工作。
你知道吗?
3条答案
按热度按时间cqoc49vn1#
OK so I just checked the
ionic capacitor run
command options docs and saw this:Tried it... and it works.
running my app with:
ionic capacitor run android -l --external
worked on the same wi-fiepfja78i2#
对我有效的方法是使用ionic提供的外部URL来调用我的端点,而不是使用
localhost
当我想在模拟器/设备上进行测试时,我运行了
ionic capacitor run android --livereload --external
然后控制台显示
因此,为了调用我的端点,我过去常常执行
http://localhost:8080/api
,而现在必须执行http://xxx.xxx.x.xx:8080/api
zaqlnxep3#
Just another answer for someone who may encounter the problem the way I faced it:
On my computer (Windows 10) the issue was that a connection from the phone to my computer was not allowed. My network connection was configured with a guest/public profile and it did not have network detection on. I fixed this by:
ionic cap run android -l --external displays the app on the phone now