0

I have a public API that I have to use in the app. The API doesn't provide a https, so I would like to allow Cleartext access.

However I'm still supporting KitKat (API 19).

Therefore this solution <application android:networkSecurityConfig="@xml/network_security_config"> leads to the error:

Attribute networkSecurityConfig is only used in API level 24 and higher (current min is 19)

So what do I do in this case?

network_security_config

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">http://....com/json/</domain>
    </domain-config>
</network-security-config>
Houman
  • 64,245
  • 87
  • 278
  • 460
  • Thats probably a Lint warning just add `tools:targetApi="n"` it will go away . – ADM Dec 22 '20 at 12:08
  • 1
    Does this answer your question? [How to add Android Network Security Config for API less than 24](https://stackoverflow.com/questions/52691058/how-to-add-android-network-security-config-for-api-less-than-24) – ADM Dec 22 '20 at 12:08
  • Ah yes, seems like a lint issue after all. Thanks – Houman Dec 22 '20 at 12:21

1 Answers1

0

You can set another attribute:
<application android:usesCleartextTraffic="true">

sdex
  • 3,169
  • 15
  • 28
  • Same problem. `Attribute usesCleartextTraffic is only used in API level 23 and higher (current min is 19)` – Houman Dec 22 '20 at 12:15