2

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.

Error app\src\main\res\xml\network_security_config.xml:4: Error: Missing includeSubdomains attribute [NetworkSecurityConfig] <domain>localhost</domain>

i tried multiple solutions, but doesn't work for me.

Reference

How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?

How Cordova support Network Security Config introduced by Android 7.0?

Could someone help me with this?

1 Answers1

5

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>
yazantahhan
  • 2,950
  • 1
  • 13
  • 16
  • yazantahhan thank you for your answer it fix the issue of includeSubdomains attribute, but on build it does show some other errors. before this error was not there **Error** `Explanation for issues of type "MissingDefaultResource": If a resource is only defined in folders with qualifiers like -land or -en, and there is no default declaration in the base folder (layout or values etc), then the app will crash if that resource is accessed on a device where the device is in a configuration missing the given qualifier.` looking forward to hear from you. – Dd5d5dyoudodoydooAhsan Mustafa Oct 29 '19 at 16:28
  • Can you try to enter `ionic cordova resources` then try to build – yazantahhan Oct 29 '19 at 16:51
  • If this didnt work, try to remove the platform and add it again – yazantahhan Oct 29 '19 at 16:52
  • firstly i do remove the platform, then build cordova resources, then add platform when i run this command `ionic cordova build android --prod --release` it does generate the config.xml file in android platform also right?, there the link of resources is getting wrong in that config file. – Dd5d5dyoudodoydooAhsan Mustafa Oct 29 '19 at 17:34
  • I didn't get this error before actually. Which file is he complaining about? Is it some of the splash screen images? Maybe this thread is related https://github.com/apache/cordova-android/issues/689 – yazantahhan Oct 29 '19 at 21:17
  • Reference folder `platforms\android\app\src\main\res\drawable-port` it is about splash screen images, and this thread is related https://github.com/apache/cordova-plugin-splashscreen/issues/214. its happen in cordova 9.0 build. too resolve this issue do i need to downgrade the cordova version. – Dd5d5dyoudodoydooAhsan Mustafa Oct 30 '19 at 05:53
  • **Error Screen** https://i.stack.imgur.com/0Rte3.png have a look in this error. – Dd5d5dyoudodoydooAhsan Mustafa Oct 30 '19 at 06:04
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/201579/discussion-between-yazantahhan-and-ahsan-mustafa). – yazantahhan Oct 30 '19 at 06:42