Skip to content

luucaohoanq/kotlin-mvvm-starter

Repository files navigation

Kotlin MVVM Sample App

  • This is a sample Android application built using Kotlin, MVVM architecture, and Jetpack Compose. It demonstrates best practices in Android development, including dependency injection with Hilt, state management with ViewModel, and UI design with Jetpack Compose.

🖼 Screens

📱 Screen Previews
Home 3
Home 3
Home 1
Home 1
Home 2
Home 2
Favorite Item
Favorite Item
Camera Detail
Camera Detail
Camera Detail With Like
Camera Detail With Like
Account Under Development
Account Under Development
Settings
Settings
Splash Screen
Splash Screen

Splash Screen

Icon

  • Copy all inside Sources/IconKitchen-Output/android/res/ to app/src/main/res/ (overwrite existing files)
  • Change app/src/main/AndroidManifest.xml to use the new icon, name is hoang_ic_launcher, default is ic_launcher and ic_launcher_round
<application
        android:icon="@mipmap/hoang_ic_launcher"
        android:roundIcon="@mipmap/hoang_ic_launcher">
</application>

Environment variables config

  • local.properties
my.api.key=YOUR_API_KEY
  • build.gradle.kts: update defaultConfig to read from local.properties and enable buildConfig feature
defaultConfig {
    /// Existing configurations...

    // Read from local.properties
    val properties = Properties()
    if (rootProject.file("local.properties").exists()) {
        properties.load(project.rootProject.file("local.properties").inputStream())
    } else {
        throw RuntimeException("local.properties file not found")
    }

    val error = "variable not found in local.properties"

    // Define BuildConfig fields without revealing fallback values
    buildConfigField(
        "String", "YOUR_API_KEY",
        "\"${properties.getProperty("my.api.key") ?: throw RuntimeException(error)}\""
    )
}

buildFeatures {

    // Existing features...

    // Environment variable configuration
    buildConfig = true
}