Get Current User Location in Jetpack Compose Using Clean Architecture — Android
In this article, you will learn how to implement location services in your Android app with Jetpack Compose and Clean Architecture.
What is Clean Architecture?
This uses the separation of concerns making it easier to write and maintain scalable applications and also makes the applications easier to test.
To achieve the separation of concerns, we are dividing the application into three layers: ui
/presentation
, domain
, and data
. Let’s take them one by one and analyze what they contain.
ui
/presentation
— Contains the UI components, screens, and UI logic such as ViewModels.
domain
— Contains the business logic, which is a set of rules that must be implemented. This is a middleman between the data
and the ui
layers.
data
— Contains the data-related logic such as network requests, databases, DTOs (Data Transfer Objects), etc… Also, the data
layer doesn’t have direct access to the ui
layer.
Setup
Firstly, let’s add the plugins to the project build.gradle
.
plugins {
id("com.google.dagger.hilt.android") version "2.45" apply false
}