A weather application built with Kotlin and Jetpack Compose that fetches current weather and a 7-day forecast for the user's location or a searched city using the OpenWeatherMap API. It supports offline mode by caching weather data locally.
- Android Studio installed (latest stable version recommended).
- A working internet connection.
- Basic knowledge of Kotlin and Android development.
-
Clone the repository:
git clone <repository_url> cd <repository_name>
-
Open the project in Android Studio:
- File > Open > Select the cloned folder.
-
Sync the Gradle files:
- Click
Sync Nowin the notification bar or go toFile > Sync Project with Gradle Files.
- Click
-
Ensure the required dependencies are installed in your
build.gradlefiles:- Jetpack Compose
- Volley for networking
- Location Services
-
Update the package name if necessary:
- Refactor > Rename > Update package name throughout the project.
- Sign up for an account at OpenWeatherMap.
- Generate an API key:
- Go to your account dashboard.
- Click on
API Keys. - Create a new API key.
- Add your API key to the project:
- Open the file where the
fetchWeatherDataandfetchWeatherDataFromGeoLocfunctions are implemented. - Replace
<your_api_key>with your generated API key:val apiKey = "<your_api_key>"
- Open the file where the
- Open the project in Android Studio.
- Connect your Android device or start an emulator.
- Build and run the project:
- Click the green "Run" button or press
Shift + F10.
- Click the green "Run" button or press
- Allow location permissions on the device/emulator when prompted.
- Use the search bar to find weather data for specific cities or wait for the app to fetch data for your current location.
-
Offline Mode:
- If there is no cached data, the app cannot display weather information.
- Cached data does not auto-update when coming back online.
-
API Rate Limiting:
- The OpenWeatherMap API has rate limits for free accounts. Upgrade your plan if the app exceeds these limits.
-
Location Permissions:
- The app requires location permissions to fetch weather for the current location. If permissions are denied, the feature will not work.
-
Error Handling:
- Limited error messages are displayed for API errors and connection issues. Enhance error feedback for better UX.
-
UI Scaling:
- Some UI elements may not scale properly on very small or large devices. Additional optimization is needed.
Feel free to fork this repository and submit pull requests for enhancements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.
