When using:
ionic cordova run android --livereload
I get the following error on my device:
so the problem is the ERR_CLEARTEXT_NOT_PERMITTED . I have try it to add to my manifest but unfortunately the manifest is overwritten after
ionic cordova run android --livereload
5 Likes
Just happen the same to me. Add this to config.xml
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
2 Likes
IO-zlu
May 21, 2019, 11:47am
3
I’ve tried the config.xml version, but couldn’t get a result.
Then i’ve read solutions about
android:networkSecurityConfig="@xml/network_security_config"
In the config.xml
we automatically get an edit-config
property which puts the network_security_config.xml
into equation.
When we look at this xml property’s source file we see the cleartextTrafficPermitted="true"
and as a sub-property <domain>localhost</domain>
.
So i’ve added
<domain>PORT_MY_APP_RUNNING_ON</domain>
(i.e. <domain>123.456.7.8</domain>
)
5 Likes
gari
May 21, 2019, 6:20pm
4
@IO-zlu I have tried your solution (because, like you I had no results with the config.xml) but my changes in the network_security_config.xml are overwritten and it does not work.
How did you do to prevent this ?
I suppose you’re trying to change the target
network xml.
You have to change the source
file. You can find the path of the source from config.xml
.
Edit:
Didn’t have my computer with me when i was writing this reply.
I’m appending path to source
file.
resources/android/xml/network_security_config.xml
1 Like
gari
May 23, 2019, 1:07pm
6
Ha, yes did not see that.
Thanks… it is working
Same problem, but not fixed with
resources/android/xml/network_security_config.xml
change… still overwritten somehow
1 Like
I formatted my pc, install latest ionic. Now non of the solutions above works. Any ideas?
Edit: nevermind, i solve it like IO-zlu suggested
1 Like
I had the same problem. The solution is to modify the file “config.xml”:
Before I had:
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:networkSecurityConfig="@xml/network_security_config" />
<application android:usesCleartextTraffic="true" />
</edit-config>
<resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
I commented on both lines and left only the following code:
<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>
and it works well
5 Likes
NurGuz
June 17, 2019, 7:45am
10
Doesn’t work for me Any idea or solution?
2 Likes
Use the below command to livereload, it will work
ionic cordova run android --device -l --ssl --debug
6 Likes
Same Problem help me on this
muthus
July 2, 2019, 7:31am
14
Maybe you can try some of these things:
Check your config.xml
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:networkSecurityConfig="@xml/network_security_config" />
<application android:usesCleartextTraffic="true" />
</edit-config>
<resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
<allow-navigation href="*" />
You enter all domains, localhost, webservices / api, upload url, etc at resources/android/xml/network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain>localhost</domain>
<domain>api.example.id</domain>
<domain>www.youtube.com</domain>
</domain-config>
</network-security-config>
You can clean and reload the Android Platform & AndroidManifest.xml
cordova clean android
5 Likes
same problem any solutions ??
this work <domain>PORT_MY_APP_RUNNING_ON</domain>
(i.e. <domain>123.456.7.890</domain>
)
I’m unable to add
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge"
…
on config.xml, because at every build that line is removed (I don’t know why)
2 Likes
It’ll work fine if you add the config to network_security_config.xml in the resources/android/xml folder.
change it like,
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">localhost</domain>
<domain includeSubdomains="true">Your server ip or domain address</domain>
</domain-config>
</network-security-config>
remember not to include http:// and port number in it.
For Eg: if your server is running at http://123.456.789.00:8080 , then the config should be,
<domain includeSubdomains="true">123.456.789.00</domain>
6 Likes
rekk
August 24, 2019, 4:52am
19
this works for me! thanks. my env: ionic 5.2.3
I am also put this but i build the application added lines are removed.
This is my problem in ionic 4. Help me to solve this error. Link is below
Link