Networking and Logging with KMM
A presentation for the Android254 community on handling networking and logging with Kotlin Multiplatform Mobile.
Introduction
In this presentation, I get into the essential aspects of networking and logging in Kotlin Multiplatform Mobile (KMM).
When it comes to logging, I emphasize its importance in monitoring, debugging, and ensuring application stability. I introduce Kermit, a logging library specifically designed for KMM by Touchlab. I walk through the process of adding the Kermit dependency, creating and customizing loggers, logging events, and even streaming logs.
On the networking side, I highlight why traditional tools like Retrofit, while powerful, are not ideal for KMM projects due to their dependency on platform-specific APIs and Java classes. Instead, I showcase Ktor, a lightweight and versatile networking library built for multiplatform use. I explain the steps to integrate Ktor into a KMM project, from adding dependencies and initializing a networking client to setting up an SDK and making network requests.
Finally, I tie everything up together and showcase a Chat application to demostrate the logging procedures and networking for both REST and Socket events. The server in running on Ktor Server.
Presentation
This presentation is not recorded. It was presented to a live audience at iHub, Nairobi Kenya.
Presenting KMM networking and logging at iHub
Slide illustrating logging with KMM
Sample
This is a screengrab of the sample used for the demo.
KMM Networking & Logging App Demo
Resources
You can download this presentation from this link.
You can view source code for this presentation from this link.