0

I installed my app on different versions and it works find , I recently tried to install it on android api 28 (android 9 ) and it doesn't get the data from internet and it shows me this error : "Cleartext HTTP traffic not permitted"

after some searched , i've tried some approaches, i've tried some of them and finally reach to this

I created a file in xml directory :network_security_config

    <?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">marketaghili.ir</domain>
    </domain-config>
</network-security-config>

and add this line to my application in manifest :

android:networkSecurityConfig="@xml/network_security_config"

after that I made my apk file but its not installing , it just says the app not installed .

How can I fix this ?

Nikunj Paradva
  • 15,332
  • 5
  • 54
  • 65
Navid Abutorab
  • 1,667
  • 7
  • 31
  • 58
  • Uninstall manually then reinstall ? You can also check if it doesn't come from Google Play Protect (something like "verify app installed via usb" in developper settings too) – Kilarn123 May 20 '19 at 12:28
  • @Kilarn123 i've tied , it doesn't work – Navid Abutorab May 20 '19 at 12:56
  • You need to add `android:usesCleartextTraffic="true"` to `application` tag in manifest file. Also must be sure url starts with `https` not `http` – Piyush May 20 '19 at 12:59
  • @Piyush we don't have ssl for our site , I don't think android make us to use https , I tried this code, still not installing – Navid Abutorab May 20 '19 at 13:09
  • The code should be ok if `marketaghili.ir` is valid. The installation problem might come from something else. – Kilarn123 May 20 '19 at 13:26
  • @Kilarn123 the domain is ok and it's running , when I remove "android:networkSecurityConfig="@xml/network_security_config" , it installs but it returns the "Cleartext HTTP traffic not permitted" error , I'm really confused – Navid Abutorab May 20 '19 at 13:54
  • Well you can try `android:usesCleartextTraffic="true"` directly in your manifest as @Piyush suggested, it should accept http trafic. the two ways work on my projects so there is no reason it wouldn't work in one of yours – Kilarn123 May 20 '19 at 13:56
  • Possible duplicate of [Android 8: Cleartext HTTP traffic not permitted](https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted) – Zoe Jun 14 '19 at 19:27

1 Answers1

0

Synchronize AndroidManifest.xml

vinuales
  • 31
  • 2