2

We send an HTTP request to a device on a local network (192.168.1.1) in an Android app. The device only accepts HTTP not https requests. It was working until the Android system update yesterday (T837VVRU1BSC3). Now cleartext traffic is rejected.

I have tried the following without success:

  1. android:usesCleartextTraffic="true"

  2. adding android:networkSecurityConfig="@xml/network_security_config" and

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">192.168.1.1</domain>
    </domain-config>
</network-security-config>
  1. changing the xml file to:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
</network-security-config>

These are the only suggested solutions I can find to permit cleartext traffic. Does anyone know of other solutions?

guipivoto
  • 18,327
  • 9
  • 60
  • 75
markelc
  • 354
  • 2
  • 14
  • Possible duplicate of [Android 8: Cleartext HTTP traffic not permitted](https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted) – Zoe Jun 14 '19 at 19:27

2 Answers2

3

Add the below line in the manifest in the application tag where icon, label, theme is defined

android:usesCleartextTraffic="true"
Deepak Goyal
  • 4,747
  • 2
  • 21
  • 46
0

Add the "android:usesCleartextTraffic="true" in the AndroidManifest.xml is okey

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar"
    android:usesCleartextTraffic="true">
Matrix
  • 503
  • 3
  • 17