Anroid Studio warning “ Setting <base-config cleartextTrafficPermitted=”true“/> is not recommended.”

江枫思渺然 提交于 2020-01-25 06:38:10

问题


I am integrating payUmoney with my app. For android above 9 cleartextTrafficPermitted="false" by default. So I get the following error -

The webpage at hhtp://180.179.174.15:3000/pgSimulator/axis/redirect could not be loaded because: net::ERR_CLEARTEXT_NOT_PERMITTED

So in network_secrity_config.xml, I change it to true as below--

  <?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true"/>
</network-security-config>

And now Android studio shows

     Setting  <base-config cleartextTrafficPermitted="true"/> is not recommended. 

Now is it safe to set it to false? If I don't set it to false. PayUmoney does not work. So what to do now?


回答1:


Either use

<application
    ...
    android:usesCleartextTraffic="true">
    ....
</application>

Or set config like below with domain:

<network-security-config>
  <domain-config cleartextTrafficPermitted="true">
    <domain includeSubdomains="true">Your_domain</domain>
  </domain-config>
</network-security-config>


来源:https://stackoverflow.com/questions/58898140/anroid-studio-warning-setting-base-config-cleartexttrafficpermitted-true

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!