Skip to content
Advertisement

Android Studio Retrofit Call Failure

I’m trying to use Retrofit in my app via Java. I’m using this worldtime API. You can call this URL in your browser to see the response : http://worldtimeapi.org/api/timezone/Europe/Istanbul (response comes too late, just refresh your browser)

I added this line to my AndroidManifest.xml

JavaScript

I added these to gradle

JavaScript

I only want to see few keys of response, so I created a class TimeForIstanbul.java

JavaScript

I created my interface ApiService.java

JavaScript

And simply I edited my MainActivity.java

JavaScript

And when I run this app, I see

JavaScript

on logcat so it goes to onFailure. What am I missing? What is wrong here? My resource for this example is this video

Advertisement

Answer

What you have to do to solve the problem is add this on my manifest.xml

JavaScript

But you may have to use other approaches you can take a look on android-8-cleartext-http-traffic-not-permitted.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement