在res/xml下新建文件(文件名任意,我的文件名为:cer.xml),文件格式:xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config xmlns:android="http://schemas.android.com/apk/res/android">
<base-config cleartextTrafficPermitted="true">
<certificates src="system" overridePins="true" />
<certificates src="user" overridePins="true" />
</network-security-config>
在AndroidManifest.xml application标签中配置
<application
android:networkSecurityConfig="@xml/cer"
>
// activity等配置项...
</application>
网友评论