ERR CLEARTEXT NOT PERMITTED in debug app on Android — Simple Solution(Android Native, IONIC , ReactNative, Xamarin)

Abhijit chakra
2 min readMay 31, 2020

--

Dont worry!!!

This is common issue while you trying to pull some resource from server with HTTP.

So before that lets understand what is CLEARTEXT

What is CLEARTEXT

Cleartext is transmitted or stored text that has not been subjected to encryption and is not meant to be encrypted.

So here in case of Android we CLEARTEXT means we and sending or pulling some information from server that is not secure & unencrypted (sends over HTTP)

So there is potential risk on the information which are sends over http to be hacked or misused .So from Android 9 i.e API 28 level onwards google decided to disable CLEARTEXT(i.e information over HTTP) by default.

But sometimes while doing development we need some URL’s that need to access via HTTP .

SOLUTION 1:

if you know which domain you want to Access through HTTP..

You can create a network_security_config.xml file under your res/xml directory

inside the file network_security-config.xml write down the domain you want to be whitelisted

<?xml version=”1.0" encoding=”utf-8"?>

<network-security-config>

<domain-config cleartextTrafficPermitted=”true”>

<domain includeSubdomains=”true”>youdomain.com</domain>

</domain-config>

</network-security-config>

and you should reference the file in AndroidManifest.xml like below

<manifest android:networkSecurityConfig="@xml/network_security_config"

SOLUTION -2

Otherwise you can whitelist all the URL for that simple you can enable it from AndroidManifest.xml file

android:usesCleartextTraffic="true"

which is not advised potential to security risk

Let me know if you not able to solve the ERR CLEARTEXT NOT PERMITTED

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Responses (3)

Write a response