- Mastering Android Development with Kotlin
- Milo? Vasi?
- 211字
- 2021-07-02 15:20:54
Additional libraries
We configured our build types and flavors, now we will need some third-party libraries. We will use and add support for Retrofit, OkHttp, and Gson. This is an explanation for each of them:
- Retrofit is a type-safe HTTP client for Android and Java by Square, Inc. Retrofit is one of the most popular HTTP client library for Android as a result of its simplicity and its great performance compared to the others.
- OkHttp is an HTTP client that's efficient by default--HTTP/2 support allows all requests to the same host to share a socket.
- Gson is a Java library that can be used to convert Java objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object. Gson can work with arbitrary Java objects including preexisting objects that you do not have a source code for.
There are a few open source projects that can convert Java objects to JSON. Later in this book, we will add Kotson to provide Gson bindings for Kotlin.
Let's extend build.gradle with dependencies for Retrofit and Gson:
dependencies { ... compile 'com.google.code.gson:gson:2.8.0' compile 'com.squareup.retrofit2:retrofit:2.2.0' compile 'com.squareup.retrofit2:converter-gson:2.0.2' compile 'com.squareup.okhttp3:okhttp:3.6.0' compile 'com.squareup.okhttp3:logging-interceptor:3.6.0' ... }
After you updated your Gradle configuration, sync it again when asked!
推薦閱讀
- Python高級編程
- Visual C
- Scala編程實戰(原書第2版)
- Java:High-Performance Apps with Java 9
- Apache Spark 2.x for Java Developers
- C# 8.0核心技術指南(原書第8版)
- Visualforce Developer’s guide
- Hadoop大數據分析技術
- 并行編程方法與優化實踐
- Data Science Algorithms in a Week
- .NET 4.0面向對象編程漫談:應用篇
- MySQL 8從零開始學(視頻教學版)
- 你真的會寫代碼嗎
- Google Maps JavaScript API Cookbook
- 瘋狂Ajax講義(第3版)