Reputation: 671
After updating ionic and cli. I suddenly started facing net::ERR_CLEARTEXT_NOT_PERMITTED whenever calling a Rest API on actual android device.
Upvotes: 1
Views: 592
Reputation: 671
I solved this by
adding
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:usesCleartextTraffic="true" />
</edit-config>
to config.xml.
Then add
<access origin="*" /> <allow-navigation href="*" />
to /resources/android/xml/network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">yourdomain.com</domain>
</domain-config>
</network-security-config>
to config.xml in the widget inside the <platform>
for android.
Then
ionic cordova platform rm android
and
ionic cordova platform add [email protected]
Upvotes: 1