You are currently viewing Why my network requests are not working in Android Pie?
Android Pie

Why my network requests are not working in Android Pie?

Why my network requests are not working in Android Pie?

Related Question is How to resolved network request related issue in Android Pie for my Android application?

If you are an Android developer and facing issue related to network request in Android Pie then here is the solution for you.

If you are using server URL with HTTP instead of HTTPS (Secure server with SSL) then you may be facing network request related issue in your Android application with Android Pie. Meaning is simple Android Pie required secure server connection.

For example:

http://server-name.com – work fine in all versions of Android except Android Pie.

https://server-name.com – work fine in all versions of Android.

[Solutions]

  1. Change the server URL with secure HTTPS in your application if possible (recommended).
  2. Implement the following logic for a quick fix. (Without changing server URL and no needs to implement SSL).

For the second solution, we need to allows our server URL for network traffic.

Step 1: Create a network_security_config file in the xml folder and add the following xml code. (file name: network_security_config.xml)

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">server-name.com</domain>
    </domain-config>
</network-security-config>

Here server-name.com is your server name without Http (i.e. your insecure server URL).

Step 2: Include network_security_config.xml file in the Android manifest.

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

That’s all done!

Rebuild your app and run it again in the Android Pie device.

You may also like my other Android related posts: Android Posts