0

I am developing an Android Application with Restful architecture using the Retrofit library. Everything worked in a certain part of the project, but this has changed in the last time. All links defined in the codes are defined, the IP address that I use for the localhost that has internet permission for the application, and this application works flawlessly on Genymotion or all different Android phones. But only the requests that I send to my service for my mobile phone give errors.

In the code example, I'll give below, the requests I've tried from all devices are entering the onResponse method and entering the onFailure part of my device.

@Override
public void onFailure(Call<ProfileP> call, Throwable t) {
    Toast.makeText(getActivity(),"Check your internet connection!", Toast.LENGTH_SHORT).show();
}

I need to run this application on my own device.

Zoe
  • 27,060
  • 21
  • 118
  • 148
  • 2
    What is your emulator and real device SDK versions? Did you try different networks? Did you define connection timeout? – Mete May 10 '19 at 20:30
  • Yes I tried with different network. It just works on other devices because I think it's a problem. – Mehmet Serkan Ekinci May 11 '19 at 07:47
  • Please log the error with `Log.e("TAG", t.getMessage());` instead of showing temporary Toast message. Or use `Toast.makeText(getActivity(), t.getMessage(), Toast.LENGTH_SHORT).show();` And [edit] the question, post the error log here. – Shashanth May 11 '19 at 08:36
  • I did that you say. And result is "CLEARTEXT comminication to 192.168.1.107 not permitted by network security policy" @Shashanth – Mehmet Serkan Ekinci May 11 '19 at 13:32
  • I searched the result of printing the error message and finally solved the error. Thanks for your help. Manifest dosyası içerisindeki application'in içerisin In the Manifest file, inside the application's android: usesCleartextTraffic = "true" code, the localhost stream allowed. For more information, visit https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted – Mehmet Serkan Ekinci May 11 '19 at 13:42
  • Possible duplicate of [Android 8: Cleartext HTTP traffic not permitted](https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted) – Tsyvarev May 13 '19 at 12:49

0 Answers0