Build Failed when ionic cordova run android

I get error while run android , please Help !!.

Hi, @Firsya
Add the following lines to your platforms/android/build.gradle

  configurations.all {
        resolutionStrategy {
            force 'com.android.support:support-v4:27.1.0'
        }
    }

if still having issue try running this command:

cordova plugin add cordova-android-support-gradle-release --fetch

Hi @addwebsolution thank u for your respon,

i have try your solutions, but there is still getting error when ionic cordova run android

Note: Recompile with -Xlint:deprecation for details.
D:\Mobile\Dev\myapp\platforms\android\res\xml\config.xml:33:53-81: AAPT: No resource found that matches the given name (at ‘networkSecurityConfig’ with value ‘@xml/network_security_config’).

D:\Mobile\Dev\myapp\platforms\android\build\intermediates\res\merged\debug\xml\config.xml:33: error: Error: No resource found that matches the given name (at ‘networkSecurityConfig’ with value ‘@xml/network_security_config’).

FAILURE: Build failed with an exception.

Hi,
have you tried both the solutions?

yes , i try both solutions but still getting error

Hi,
Please fire these commands first and then try to build app may be your problem can be solved by doing this:

cordova platform rm android
cordova platform add android
1 Like

Hi I try to add network_security_config.xml in platforms\android\build\intermediates\res\merged\debug\xml

<?xml version="1.0" encoding="utf-8"?>

its works for me, but i dont know what effect it has

reference https://codelabs.developers.google.com/codelabs/android-network-security-config/#3

1 Like

@Firsya hai, I have did these changes as you said. I am getting an error like String types are not allowed at networkSecurityConfig. Can you please help me to resolve it. I got struct with this error from past 3 days. Thanks in Advance!

hii, can you show your error ?

Hai Firsya, Now i have solved this issue by creating a new project and installing all the packages again. May be issue with some package. Thanks for the response.

this problem comes from the mismatch project environment and executing platform environment.
try to create a new project and run in the same platform environment.

however, this issue can resolve by editing your config.xml file.

<platform name="android">
+        <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
             <application android:networkSecurityConfig="@xml/network_security_config" />
         </edit-config>
+        <resource-file src="resources/android/xml/network_security_config.xml" target="res/xml/network_security_config.xml" />
         <allow-intent href="market:*" />

more

It works for me also, tks <3