Skip to content

Instantly share code, notes, and snippets.

@jignesh8992
Created July 21, 2022 16:22
Show Gist options
  • Select an option

  • Save jignesh8992/776e43c942ff89b3d8bcf9d314829e2f to your computer and use it in GitHub Desktop.

Select an option

Save jignesh8992/776e43c942ff89b3d8bcf9d314829e2f to your computer and use it in GitHub Desktop.
Easy project setup for simple mvvm with dagger-hilt android project

Dependency


Include the library in your project level build.gradle

buildscript {
    dependencies {
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0" // For navigation graph
        classpath 'com.google.dagger:hilt-android-gradle-plugin:2.42' // For dagger-hilt
    }
}

Include the following plug-in and library in your app level build.gradle

plugins {
    id 'kotlin-kapt'
    id 'androidx.navigation.safeargs.kotlin' // For navigation graph 
    id 'dagger.hilt.android.plugin' // For dagger-hilt
}

android {   

    buildFeatures {
        viewBinding true // For view binding
    }
}

dependencies {

    // Architectural Components
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0"

    // Room
    implementation "androidx.room:room-runtime:2.4.2"
    kapt "androidx.room:room-compiler:2.4.2"

    // Kotlin Extensions and Coroutines support for Room
    implementation "androidx.room:room-ktx:2.4.2"

    // Coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1'

    // Coroutine Lifecycle Scopes
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.0"

    // Retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation "com.squareup.okhttp3:logging-interceptor:4.5.0"

    // Navigation Components
    implementation "androidx.navigation:navigation-fragment-ktx:2.5.0"
    implementation "androidx.navigation:navigation-ui-ktx:2.5.0"

    // Glide
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    kapt 'com.github.bumptech.glide:compiler:4.12.0'

    // Dagger Hilt
    implementation 'com.google.dagger:hilt-android:2.42'
    kapt 'com.google.dagger:hilt-compiler:2.42'
    kapt 'androidx.hilt:hilt-compiler:1.0.0'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment