0

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?

a_local_nobody
  • 7,947
  • 5
  • 29
  • 51
Junior
  • 170
  • 2
  • 10
  • Go through this link you'll find a solution https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted – Usama Altaf Feb 26 '21 at 09:30
  • I am coming here after reading all the comments there. They confused me, everyone saying different stuff. I need a solution for this specific case, which wasn't mention there. – Junior Feb 26 '21 at 09:33

0 Answers0