I have a strange issue. My app is using http to connect to a server. It works fine in many devices. However, in Xiaomi devices which has Android 9, it gives me this error:
Caused by java.io.IOException: Cleartext HTTP traffic to internet.vodafone.com.eg not permitted at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:142) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:469) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:418) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:549) at com.google.firebase.perf.network.zzd.getResponseCode(zzd.java:81) at com.google.firebase.perf.network.zzb.getResponseCode(zzb.java:14) at com.android.volley.toolbox.HurlStack.executeRequest(HurlStack.java:96) at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:123) at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:131) at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111) at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)
In the AndroidManifest.xml I have this:
<application ... android:networkSecurityConfig="@xml/network_security_config" ... </application>
My network_security_config.xml file:
<?xml version="1.0" encoding="utf-8"?> <network-security-config> <domain-config cleartextTrafficPermitted="true"> <domain includeSubdomains="true">thebondnews.com</domain> </domain-config> </network-security-config>
Also, I have all the permission to connect to the internet. It works fine in Many devices with android 9 Like Samsung galaxy s9/s9+ and Samsung galaxy s8/s8+ and many others.
The error message was copied from Firebase Crashlatics. What is strange is that my server domain is thebondnews.com but in the log, it says internet.vodafone.com.eg
or sometimes notification.etisalat.com.eg
and 10.10.10.1
. It is like there is kinda redirection in their devices.
Can anyone help me how to solve it? or what shall I do?
Update 1: Could it be that I am only allowing my domain in network_security_config.xml and because of the redirection caused by their providers the connection fails?
Advertisement
Answer
As Md. Asaduzzaman said in the comments.
The internet package of that user has finished and the operator tries to redirect him to the internet package page.
So it was not an issue with the app. However, some users have a limited internet package with limited access to things like Facebook, WhatsApp, Instagram..etc.
Thus, when my app tries to connect to the server, it is being redirected by the internet provider to block the traffic.