![]() Scalars: 2:converter-scalarsįor the purposes of this tutorial, I’ve picked the Jackson library, so we need to add the following to file: implementation("2:converter-jackson:2.9.0")Īs the next step, let’s see how can we configure Retrofit to work with Kotlin.Thankfully, we can achieve that pretty easily by importing desired Converter to our project: Although sometimes it might be sufficient, in most cases we would like to make use of some serialization library when dealing with payloads. Serialization & Deserializationīy default, Retrofit allows us to work only with OkHttp’s RequestBody and ResponseBody objects. If you are working with Maven, then you can add it to your project with the following lines: Īlternatively, we can use Gradle to fetch the library: // adle In my examples, I will be using version: 2.9.0. Moreover, depending on when you are reading this article, the latest stable version can be different and I recommend using the latest one. It’s worth mentioning, that Retrofit requires at minimum Java 8+ or Android API 21+, so it won’t be compatible with the legacy codebase. If you are looking for a library, which will help you to integrate external API in your mobile application, or a back-end service written in Java or Kotlin, then Retrofit is definitely worth a try. Let’s start by answering the question: what exactly the Retrofit is? It is a type-safe HTTP client for Android and Java. I will walk you step by step through its features, capabilities and a few obstacles you may encounter when using it. This time, I would like to show you how to use Retrofit 2 with Kotlin.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |