android - 为什么 volley 库不能在 android 9(API 28) 上工作,而在 android 8(API 27) 上工作正常?

标签 android android-volley

我正在开发一个带有 volley 库的应用程序。 android 9.0以下一切正常。但在 9.0 中则不然

我正在使用

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

梯度:3.2.1

最佳答案

从 android 9 起禁止明文流量。您需要手动允许它将以下代码添加到 list 中。

android:networkSecurityConfig="@xml/network_security_config"

此外,创建 xml/network_security_config.xml 并添加以下代码以允许明文流量:

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

关于android - 为什么 volley 库不能在 android 9(API 28) 上工作,而在 android 8(API 27) 上工作正常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53927708/

相关文章:

android - 将附加字符串附加到 SimpleCursorAdapter

Android AsyncTask onPreExecute 未被不确定地调用

java - 从我的 JSON 解析器获取空指针异常

android - 如何执行 "RXJava 2 queue jobs"直到值改变?

android - RecyclerView 中的 NetworkImageView 因回收而导致显示问题

java - 字符串请求发布未显示任何错误

android - 像 Google+ 应用中一样 ScrollView

java - 如何在 Android Volley 中创建一个新的 newRequestQueue

android - 禁用或删除 NetworkImageView-Volley 中的缓存

android - 如何在android中的截击中发送参数数组