why volley library not working on android 9(API 28) where as its working fine on android 8(API 27)?

Viewed 8795

I am developing an app with volley library. Everything is working fine below android 9.0. But not in 9.0

I am using

implementation 'com.android.volley:volley:1.1.0'
targetSdkVersion 28
compileSdkVersion 28
minSdkVersion 24

gradle:3.2.1

4 Answers

From android 9 clear text traffic is prohibited. You will manually need to allow it adding below code to manifest.

android:networkSecurityConfig="@xml/network_security_config"

Also, create xml/network_security_config.xml and add below code to allow clear text traffic:

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

Update :

Please add below line in manifests:

android:usesCleartextTraffic="true"

First, You check your Offline mode is check or Unchecked. if it's check then please go on setting and Unchecked.

Now change the below version :

compileSdkVersion 27
minSdkVersion 16
targetSdkVersion 27

implementation 'com.android.support:appcompat-v7:27.1.1'

implementation 'com.android.volley:volley:1.1.0'

Now Clean and Re-Build your Project.

Just add one line manifest file.

 android:usesCleartextTraffic="true"

I have same problem and resolved it when I use https not http.

Related