1
votes

I am getting a problem to run my ionic cordova app on android 9 its working fine on android version less than 9 Application is not hitting the backend in android 9 this is my environment

I tried on samung and onePlus devices bot on android verion 9 and less than 9

Ionic:

ionic (Ionic CLI) : 4.0.0 (/usr/local/lib/node_modules/ionic) Ionic Framework : ionic-angular 3.9.6 @Ionic/app-scripts : 3.2.4

Cordova:

cordova (Cordova CLI) : 8.0.0 Cordova Platforms : android 8.0.0

System:

Android SDK Tools : 26.1.1 NodeJS : v8.10.0 (/usr/bin/node) npm : 6.9.0 OS : Linux 4.15

Environment:

ANDROID_HOME : /home/aviral/Android/Sdk

1
Did you try to set targetSDK to 29?Ali Mhanna
did you check your logcat for errors?Nidhin Joseph
okay i got it fixed. doing cordova remove platform android cordova add platform [email protected]Aviral Rajput

1 Answers

0
votes

Add network_security_config.xml in platforms\android\app\src\main\res\xml. The file contains

<?xml version="1.0" encoding="utf-8"?>
  <network-security-config>
 <base-config cleartextTrafficPermitted="true">
 <trust-anchors>
  <certificates src="system" />
  </trust-anchors>
  </base-config>
</network-security-config>

Add the above file in AndroidManifest.xml like

 <application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" 
  android:label="@string/app_name" 
  android:networkSecurityConfig="@xml/network_security_config" 
  android:supportsRtl="true">