离子网络安全配置 [英] Ionic network security config
问题描述
您好,我正在从事离子应用.通过执行此命令 ionic cordova build android --prod --release
.它会生成未分配的apk文件,但也会在network_security_config文件中显示错误.
Hello i am working on ionic application. with executing this command ionic cordova build android --prod --release
. it does generate the unasigned apk file,but it also show error in network_security_config file.
错误app \ src \ main \ res \ xml \ network_security_config.xml:4:错误:缺少includeSubdomains属性[NetworkSecurityConfig]< domain>本地主机</domain>
我尝试了多种解决方案,但不适用于我.
i tried multiple solutions, but doesn't work for me.
参考
如何允许Android(9)Pie中的所有网络连接类型为HTTP和HTTPS?
Cordova如何支持网络安全配置是Android 7.0吗?
有人可以帮我吗?
推荐答案
转到 resources/android/xml/network_security_config.xml
并添加 includeSubdomains ="true"
域属性.应该是这样的:
Go to the resources/android/xml/network_security_config.xml
and add includeSubdomains="true"
to the domain property. It should be like this:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">localhost</domain>
</domain-config>
</network-security-config>
这篇关于离子网络安全配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!