Prerequisites
Before you begin, ensure you have the following installed:Android Studio
Latest stable version with Android SDK
JDK 17
Required for Kotlin compilation
Git
For cloning the repository
Gradle
Included via Gradle Wrapper
The project uses Gradle Wrapper, so you don’t need to install Gradle separately. The wrapper scripts (
gradlew and gradlew.bat) handle everything for you.Clone the Repository
Build the Project
Using Android Studio
Once the Gradle sync completes, you can build the project:- Select Build > Make Project from the menu
- Wait for the build to complete (watch the Build output at the bottom)
Using Command Line
You can also build from the terminal:Run the Application
Configure a device
You can run the app on either:
- Physical device: Enable USB debugging in Developer Options
- Emulator: Create an AVD (Android Virtual Device) in Android Studio
Minimum SDK: API 24 (Android 7.0)
Target SDK: API 36
Target SDK: API 36
Project Structure
The project follows a multi-module architecture using “Package by Component” strategy. Here’s the complete module breakdown:Module Types
Library Modules
Library Modules
General-purpose utilities that can be reused across the project:
- cache: Key-value storage functionality (SharedPreferences wrapper)
- cache-test: Testing utilities for the cache module
- coroutines-test-dispatcher: JUnit rules for coroutine testing
- designsystem: Reusable UI components and theme
- flow-test-observer: Utilities for testing Flow emissions
- foundations: Language utilities not provided by Kotlin (e.g.,
Answertype) - httpclient: Network request handling
- viewmodel: ViewModel utilities without tight framework coupling
Component Modules
Component Modules
Pure Kotlin/KMP modules containing domain and data layers for specific features:
- cart-component: Shopping cart domain and data layers
- money-component:
Moneydomain object shared across modules - product-component: Product domain and data logic
- user-component: User authentication and data management
- wishlist-component: Wishlist domain and data layers
Component modules are implemented in Kotlin Multiplatform and have no Android framework dependencies. This makes them compile faster and potentially reusable across platforms.
UI Modules
UI Modules
Android-specific presentation layer modules:
- cart-ui: Cart screen UI components
- main-ui: Main screen with bottom navigation
- money-ui: Reusable price display components
- onboarding-ui: Login screen (and eventually account creation)
- plp-ui: Product List Page UI
- wishlist-ui: Wishlist screen components
App Module
App Module
Central orchestration module that:
- Integrates all feature modules
- Contains navigation logic (see
app/src/main/java/com/denisbrandi/androidrealca/navigation/RootNavigation.kt:1) - Manages dependency injection via
CompositionRoot(seeapp/src/main/java/com/denisbrandi/androidrealca/di/CompositionRoot.kt:1) - Defines the main
MainActivity(seeapp/src/main/java/com/denisbrandi/androidrealca/MainActivity.kt:1)
Directory Structure
Navigating the Codebase
Understanding the Architecture
The project strictly adheres to Clean Architecture principles:Domain Layer (Business Logic)
Located in component modules under
src/commonMain/kotlin/.../domain/Example: User login use caseThe
Answer type from the foundations module is used for error handling instead of exceptions.Data Layer (Repositories)
Located in component modules under
src/commonMain/kotlin/.../data/Contains repository implementations and data models (DTOs).Presentation Layer (UI)
Located in UI modules under
src/main/java/.../presentation/Example: Login ViewModelDependency Injection
The project uses manual DI through assembler classes:
- Each module has an assembler in its
di/package - The app module’s
CompositionRootorchestrates all assemblers - Dependencies are lazily initialized
app/src/main/java/com/denisbrandi/androidrealca/di/CompositionRoot.kt:1 for the complete setup.Key Files to Explore
MainActivity.kt
App entry point
app/src/main/java/com/denisbrandi/androidrealca/MainActivity.kt:9RootNavigation.kt
Navigation graph
app/src/main/java/com/denisbrandi/androidrealca/navigation/RootNavigation.kt:19CompositionRoot.kt
DI container
app/src/main/java/com/denisbrandi/androidrealca/di/CompositionRoot.kt:13Answer.kt
Error handling type
foundations/src/commonMain/kotlin/.../Answer.kt:3Running Tests
The project includes comprehensive unit tests for all layers:Test Structure
Tests are located alongside source code:- Component modules:
src/commonTest/kotlin/ - UI modules:
src/test/java/
user-component/src/commonTest/kotlin/.../domain/usecase/onboarding-ui/src/test/java/.../viewmodel/
Common Gradle Tasks
Here are the most frequently used Gradle commands:Next Steps
Now that you have the project running, explore these topics to deepen your understanding:Architecture Overview
Learn about Clean Architecture principles
Module Structure
Understand the modularization strategy
Domain Layer
Explore business logic implementation
Testing Guide
Write and run tests effectively
Troubleshooting
Gradle sync fails
Gradle sync fails
- Ensure you have JDK 17 installed
- Check your internet connection (Gradle downloads dependencies)
- Try invalidating caches: File > Invalidate Caches / Restart
- Delete the
.gradledirectory and sync again
Build errors after cloning
Build errors after cloning
- Run
./gradlew clean - Ensure Android SDK is installed with API 36
- Check that
ANDROID_HOMEenvironment variable is set - Update Android Studio to the latest stable version
App crashes on launch
App crashes on launch
- Check Logcat in Android Studio for stack traces
- Ensure the device/emulator is running at least Android 7.0 (API 24)
- Verify the build variant is set to
debug - Try cleaning and rebuilding the project
Tests failing
Tests failing
- Run
./gradlew clean test - Ensure all dependencies are downloaded
- Check if specific test files need updating
- Verify JDK 17 is being used for compilation
For more help, check the GitHub repository for issues and discussions.