Home » Android » android – Cleartext http traffic not permitted

android – Cleartext http traffic not permitted

Posted by: admin June 15, 2020 Leave a comment


I’m working in one project and I’m stuck in the implementation of login/signup page. When I try to implement the code it gives me the error Cleartext HTTP traffic to not permitted. I checked the ipconfig and that was my IPv4 so I have added, but I have also checked, but that one doesn’t work either.

I have tried implementing <domain includeSubdomains="true"></domain> however that one doesn’t work(implementation of android:usesCleartextTraffic="true" doesn’t work either).

I’m using XAMPP for the back-end and if I run php code everything works good, so no problem with that. Problem is in the Android Studio(I’m using Kotlin).

For the Emulator I’m using Genymotion emulator(it uses VirtualBox).

Here’s the code for the button that takes the url. I have checked everything, but still nothing achieved.

login.setOnClickListener {
            var url = "" + login_user.text.toString() +
                    "&password=" + login_password.text.toString()
How to&Answers:

To do this in Android 9 Pie you will have to set a networkSecurityConfig in your Manifest application tag like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
     <application android:networkSecurityConfig="@xml/network_security_config">

Then create a xml file named network_security_config just like the way you have named it in the Manifest and the content of your file should be like this👇to enable all requests without encryptions:

<?xml version="1.0" encoding="utf-8"?>
    <base-config cleartextTrafficPermitted="true">
            <certificates src="system" />

If this is not working, please make your request from a secure domain(HTTPS).


Add this into your Manifest


like this..



I also faced the same issue recently with android 9 pie.

I added in my Manifest


second line is mentioned is to ignore the warning for SDK less than 23.