Hi, perhaps someone can save me from bashing my head against this problem for another 10 hours. I have made an ionic app that communicates with a local server on my pc. This works when I ng serve or ionic serve it. I have since run it in the android emulator and the the network is entirely bugged or not working for the ionic app when running inside the android emulator.
- If I go to the google chrome browser on the emulated device and enter “http://10.0.0.2:8005”, I get back a perfect response from the running server on my local host. So I know the emulated android app is not the problem.
- For those unsure, http://10.0.0.2 is the loopback to the localhost or http://127.0.0.1 for emulated android devices.
- If I then hit that same url from within my ionic app, I get “Failed to fetch”, “Unknown Error” and “null” back if I use the standard “js fetch()”, “Angular HttpClient”, and “Ionic native http” respectively. I tried all three methods and all have the similar result.
Does anybody know why the ionic app that I created gets the above network errors when running in emulated android mode but not when being served? Yet the rest of the android device has access to the network? The most frustrating part of this is the lack of a real error, or problem. (I am not running any firewalls or proxies either).
I am running ionic 5.2.4, and the command I am using, to launch the app is:
> ionic cordova emulate android --livereload --consolelogs
In regards to the AVD, I have tried api 28 an 26, both have the same problem.
I have also done the following:
- Installed the cordova white list pluggin
- Set the cors, on/off,(client and server side)
<access origin="*"/>in the config.xml
- Destroyed and re-created the ADV multiple times
Thanks to anyone in advance who has an idea.