gpt4 book ai didi

android - org.apache.http.legacy 不适用于 API 28

转载 作者:可可西里 更新时间:2023-11-01 16:23:57 33 4
gpt4 key购买 nike

首先,我使用 org.apache.http 函数有一段时间了,当我尝试在 API 28 上启动我的应用程序时出现错误。它在 API 26 和 API 23 上工作,但 API 突然出现问题28.谷歌有没有做出一些改变?

最佳答案

要在 Android 9.0 Pie 中完美运行 org.apache.http.legacy,请创建一个 xml 文件 res/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>

并在你的AndroidManifest.xml中添加2个tags标签

android:networkSecurityConfig="@xml/network_security_config" android:name="org.apache.http.legacy"

<?xml version="1.0" encoding="utf-8"?>
<manifest......>
<application android:networkSecurityConfig="@xml/network_security_config">
<activity..../>
......
......
<uses-library
android:name="org.apache.http.legacy"
android:required="false"/>
</application>

还要在您的应用构建 gradle 中添加 useLibrary 'org.apache.http.legacy'

android {
compileSdkVersion 28
defaultConfig {
applicationId "your application id"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
useLibrary 'org.apache.http.legacy'
}

关于android - org.apache.http.legacy 不适用于 API 28,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53482314/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com