markelc
markelc

Reputation: 354

Cleartext error when sending to local ip address -- Android 9

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?

Upvotes: 2

Views: 1809

Answers (2)

Matrix
Matrix

Reputation: 581

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">

Upvotes: 0

Deepak Goyal
Deepak Goyal

Reputation: 4907

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

android:usesCleartextTraffic="true"

Upvotes: 3

Related Questions