Download Manger Not Working in Android Pie 9.0 Networksecurityconfig: No Network Security Config Specified, Using Platform Default

Download Manger not working in Android Pie 9.0 NetworkSecurityConfig: No Network Security Config specified, using platform default

This worked for me After Xiaomi mi A2 received software update notification today.

Sample Image

what worked for me

Add android:networkSecurityConfig="@xml/network_security_config" in application tag

<application
android:name=".ApplicationClass"
android:allowBackup="true"
android:hardwareAccelerated="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
android:theme="@style/AppTheme">

where network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>

Create xml under res directory and then network_security_config.xml in xml folder like in the picture below

Sample Image

This explains the issue in software

Download Manager returns unsuccessful download on Android 9.0 NetworkSecurityConfig: No Network Security Config specified, using platform default

I found the solution through here: How to solve Android P DownloadManager stopping with "Cleartext HTTP traffic to 127.0.0.1 not permitted"?

In short, I just need to do the following:

1.create res/xml/network_security_config.xml, then add

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>

2. in manifest file, reference it inside application tag

android:networkSecurityConfig="@xml/network_security_config"

For more info, can read here: https://developer.android.com/training/articles/security-config#CleartextTrafficPermitted

NetworkSecurityConfig: No Network Security Config specified, using platform default Error response code: 400

Try these solutions

Solution 1)

Add the following attribute to the <application tag in AndroidManifest.xml:

android:usesCleartextTraffic="true"

Solution 2)

Add android:networkSecurityConfig="@xml/network_security_config" to the <application tag in app/src/main/AndroidManifest.xml:

<application
android:name=".ApplicationClass"
android:allowBackup="true"
android:hardwareAccelerated="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
android:theme="@style/AppTheme">

With a corresponding network_security_config.xml in app/src/main/res/xml/:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>

Sample Image

Refer this answer for more info:
Download Manger not working in Android Pie 9.0 (Xiaomi mi A2)

How to solve Android P DownloadManager stopping with Cleartext HTTP traffic to 127.0.0.1 not permitted?

Create a XML res/xml/network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>

Reference this file in your tag Application, inside AndroidManifest.xml. Like:

android:networkSecurityConfig="@xml/network_security_config"

How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?

The easy way to implement this is to use this attribute to your AndroidManifest.xml where you allow all http for all requests:

<application android:usesCleartextTraffic="true">
</application>

But in case you want some more configurations for different links for instance, allowing http for some domains but not other domains you must provide res/xml/networkSecurityConfig.xml file.

To do this in Android 9 Pie you will have to set a networkSecurityConfig in your Manifest application tag like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
<application android:networkSecurityConfig="@xml/network_security_config">

</application>
</manifest>

Then in your xml folder you now have to create a file named network_security_config just like the way you have named it in the Manifest and from there the content of your file should be like this to enable all requests without encryptions:

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

From there you are good to go. Now your app will make requests for all types of connections. For additional information on this topic read here.



Related Topics



Leave a reply



Submit