Muhammed Salih Karakasli

Software Engineer | Mobile Development | Personal Notes

Domain based Cleartext Traffic Permission in Android Applications

A few days ago,

I faced an issue about loading some images by using Glide library. As you can guess, image URLs comes from backend services so I have tried to find common pattern between failed ones and add listener to glide request to check is there any exception during image loadings.

Yeah, the root cause was http.

Of course there are a few methods to solve this issue, for example; you can find your backend developer or system engineer to say them;

WHAAAAT? Still HTTP in 2021?? Really? But, please say that if you so close to say this 🙂


So what I did about problem?

For quick and a little bit more secure solution, I prefer to define domain based network configuration. To do that, you have to create a network-security-config file in your app.

    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true"></domain>

You can configure includeSubdomains as your needs and part also.

Than you have to set this new config file in AndroidManifest.xml


And thats it!

Have a nice coding 🙂