Before you mark this question as duplicate here me out.
I have added the res/xml/network_security_config.xml file and declared it in the AndroidManifest file but I am still getting this error:
Error while pinging URL: http://google.com. Cleartext HTTP traffic to google.com not permitted
network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
    <domain includeSubdomains="true">127.0.0.1</domain>
</domain-config>
AndroidManifest.xml
<application
    android:networkSecurityConfig="@xml/network_security_config"
    ...
</application>
Important points:
I can't use https because its coming from a library that I am using. Facebook ad mediation library to be more specific.
When I use android:usesCleartextTraffic="true" in the manifest file instead of using network_security_config file it works.
Also when I use base-config instead of domain-config inside the network_security_config (of course I change the format to use base-config) then it also works.
But as many of the developers suggested, this is not a safe solution. Can anyone tell me if it is actually safe of not?
How can I solve this issue?
 
    