Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 822
UTTAM KUMAR Avatar asked Nov 28 '22 21:11

UTTAM KUMAR


2 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>
like image 194
karan Avatar answered Dec 06 '22 09:12

karan


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.

like image 39
Ali Avatar answered Dec 06 '22 10:12

Ali