- AGP (Android Gradle Plugin):
8.5.2
Plugin for building Android apps with Gradle. - Android Compile SDK:
34
The Android version used for compiling the app. - Android Min SDK:
28
Minimum Android version required to run the app. - Android Target SDK:
34
Target Android version for the app to run on.
- androidx-activityCompose:
1.9.3
Integration of Jetpack Compose with Android Activity lifecycle. - androidx-appcompat:
1.7.0
Support for Material Design and backward compatibility for UI components. - androidx-constraintlayout:
2.2.0
Flexible layout manager for building complex layouts. - androidx-core-ktx:
1.15.0
Kotlin extensio 8000 ns for Android Core libraries. - androidx-espresso-core:
3.6.1
UI testing framework for Android. - androidx-lifecycle:
2.8.4
Android Lifecycle components for managing UI-related data lifecycle-aware. - androidx-material:
1.12.0
Material Design components for Android. - androidx-test-junit:
1.2.1
JUnit support for Android testing.
- Compose Multiplatform:
1.7.0
Cross-platform UI framework for building native applications. - Kotlin:
2.1.0
The Kotlin programming language used for the project.
- JUnit:
4.13.2
Testing framework for Java/Kotlin applications. - androidx-uiTest:
1.7.5
UI testing for Jetpack Compose.
- BigNum:
0.3.9
Library for working with arbitrary-precision numbers. - Kamel Image:
1.0.1
Image loading library for Jetpack Compose((usage-cache weather icons)). - Koin Annotations:
1.3.1
Koin annotations for dependency injection in Kotlin. - Lifecycle ViewModel Compose:
2.8.4
Compose integration with ViewModel. - Voyager:
1.1.0-beta03
Navigation library for Compose. - Napier:
2.7.1
Logging library for Kotlin and Compose. - Build Config:
5.3.5
Build-time configuration management .
- kotlinx-coroutines:
1.9.0
Kotlin library for asynchronous programming using coroutines. - ktor:
3.0.1
Kotlin framework for building server and client applications. - kotlinx-serialization:
1.7.3
Kotlin serialization library for encoding/decoding data formats like JSON. - kotlinx-datetime:
0.6.1
Kotlin extension library for working with date and time.
- SQLDelight:
2.0.2
Kotlin Multiplatform SQL library for working with databases(used to cache weather data). - Size Measurement:
0.5.0
Library for measuring UI element sizes(to adapt to different screens). - Coil 3:
3.0.0-alpha08
Image loading library for Jetpack Compose, with support for modern image formats(usage-cache weather icons).
##Preview
To set up the API key, follow these steps:
-
Open Android Studio and navigate to the
local.properties
file. -
Add the following line (without quotes):
API_KEY=<Your Plain API Key> Ensure you spell API_KEY exactly as specified to avoid errors during key generation.
-
Run the following command to build the project while generating the key:
-
./gradlew build
- Open Android Studio.
- Open the project as a whole and and not the
android
module directly to see all configurations. - In Android Studio, choose the composeApp from the run configurations drop-down.
- Click the Build button to run the project on real device or emulator.
-
Navigate to the
iosApp
folder inside the project. -
Open the
iosApp.xcworkspace
file in Xcode. -
In Xcode, select your Development Team under the Signing & Capabilities tab in the project settings.
-
Select the target device or simulator.
-
Click the Build button in Xcode to compile and run the app on the iOS simulator or device.
-
Return to Android Studio.
-
Select the iosApp target from the run configurations drop-down.
-
Click the Build button in Android Studio to compile the project and deploy the app to the iOS simulator or device.
I leveraged the power of Kotlin Multiplatform to build a unified solution that runs seamlessly across all platforms, including Android, iOS, and others. On Android, the app runs natively using Kotlin, taking full advantage of Kotlin’s features for performance and security. For iOS, I used Kotlin Multiplatform to share common business logic and manage platform-specific implementations, enabling the app to run on iOS devices while utilizing Compose UI for the user interface. This allowed me to maintain a consistent UI codebase across both Android and iOS, while also integrating platform-specific APIs and libraries. In some cases, I used Swift for iOS-specific features, leveraging Swift’s strengths for optimal integration with the iOS ecosystem, all while using Kotlin’s expect/actual mechanism for shared logic.
By sharing core business logic between platforms, I was able to reduce duplication, ensuring consistent behavior and easy maintenance.
To optimize performance, I implemented a robust caching mechanism. Weather data is stored locally, allowing the app to function smoothly even when offline. When network connectivity is available, the app intelligently updates the cached data with the latest weather information, ensuring users always receive fresh data.
Kotlin was used throughout the project, enabling both shared logic and platform-specific implementations. This approach maximized code reuse while ensuring that each platform's unique features and performance requirements were properly addressed, resulting in an optimized and secure app experience across all devices.
While integrating the API, I encountered a problem where the shared API endpoint was pointing to a HTTP URL: Enabling HTTP is generally not recommended as it compromises security-Can be enabled in android manifest
After some research, I discovered that the same API was accessible via an HTTPS endpoint, and using the HTTPS version resolved the issue. I used the same provided API key provided in the task , and the request worked as expected.