Capacitor Android not loading http javascript source #4477
-
Im trying to load remote scripts / css from my local web server under url of http://127.0.0.1:4002/ But seem to be having error in capacitor android, capacitor ios is working fine. I also manage to load the css from without any error https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap-grid.min.css My guess is not supporting http? Here is my code in loading it
Here is the error i got under 'chrome://inspect/#devices' My dependencies:
My capacitor.config.json
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You can enable port forwarding to send the 4002 port traffic to the emulator, or you can use https://developer.android.com/studio/run/emulator-networking Also, note that using |
Beta Was this translation helpful? Give feedback.
127.0.0.1
is your computer, iOS simulator understand it because the simulator is running on your computer, but on Android, the emulator is a "virtual machine" with its own networking, so127.0.0.1
for it its the own emulator, not your computer.You can enable port forwarding to send the 4002 port traffic to the emulator, or you can use
10.0.2.2
IP as it automatically loops to127.0.0.1
https://developer.android.com/studio/run/emulator-networking
Also, note that using
127.0.0.1
won't work on real devices because of the same reason, it's better if you use the local IP of the computer instead, something like192.168.1.30