org.apache.http.legacy在API 28上不起作用 [英] org.apache.http.legacy doesn't work on API 28
问题描述
首先,我使用org.apache.http函数已有一段时间,当我尝试在API 28上启动我的应用程序时出现错误.它在API 26和API 23上正常工作,但是突然API出了点问题28. Google进行了一些更改吗?
To begin with, I was using org.apache.http functions for a while now and error came when I tried to launch my app on API 28. It's working on API 26 and API 23, but suddenly something is wrong with API 28. Did Google made some changes?
推荐答案
要在Android 9.0 Pie中完美运行org.apache.http.legacy,请创建一个xml文件res/xml/network_security_config.xml
To run org.apache.http.legacy perfectely in Android 9.0 Pie create an xml file 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个标签标签
And add 2 tags tag in your AndroidManifest.xml
android:networkSecurityConfig ="@ xml/network_security_config" android:name ="org.apache.http.legacy"
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>
还要在您的应用构建包中添加useLibrary 'org.apache.http.legacy'
Also add useLibrary 'org.apache.http.legacy'
in your app build gradle
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'
}
这篇关于org.apache.http.legacy在API 28上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!