After targetSDK upgrade to 28, Android forces network requests to use https protocol. On the public server, it’s easy to do, just enable https support. And there is no website that doesn’t support https now, right?
However, this limitation is not so convenient when developing and debugging Android programs on your own computer. Probably Google has taken this into account and provided a method.
First open the local server, assuming it is running on port 3000.
Create a new
res/xml/network_security_config.xml file and reference it in AndroidManifest.xml as follows.
network_security_config.xml reads as follows
Then map the 3000 port of the phone to the 3000 port of the development machine.
Finally, just change the domain name of the service you are accessing in your code to localhost.
Addendum: Although highly discouraged, if you want the whole APP to access any network without this https protocol restriction, you can do this.