Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save virtualprodigy/f7ae65197bd11e31431cb7aa319bb923 to your computer and use it in GitHub Desktop.
Save virtualprodigy/f7ae65197bd11e31431cb7aa319bb923 to your computer and use it in GitHub Desktop.
Quick Start - Android Compose App Gradle Files
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'com.google.dagger.hilt.android'
}
android {
namespace '<com.replace.your>'
compileSdk 33
defaultConfig {
applicationId "<com.replace.your>"
minSdk 25
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.1.1'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$androidx_lifecycle_viewmodel_version"
implementation "androidx.lifecycle:lifecycle-viewmodel:$androidx_lifecycle_viewmodel_version"
implementation 'androidx.activity:activity-compose:1.6.1'
implementation "androidx.compose.ui:ui:$compose_ui_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
implementation "androidx.compose.material3:material3:$material3_version"
implementation "androidx.compose.material:material:$compose_ui_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
//networking
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
//Hilt DI
implementation("com.google.dagger:hilt-android:$hilt_di_version")
kapt("com.google.dagger:hilt-android-compiler:$hilt_di_version")
// For instrumentation tests
androidTestImplementation "com.google.dagger:hilt-android-testing:$hilt_di_version"
androidTestAnnotationProcessor "com.google.dagger:hilt-compiler:$hilt_di_version"
// For local unit tests
testImplementation "com.google.dagger:hilt-android-testing:$hilt_di_version"
testAnnotationProcessor "com.google.dagger:hilt-compiler:$hilt_di_version"
//Testing Frameworks
//mockito
testImplementation "org.mockito:mockito-core:4.8.1"
testImplementation "org.mockito.kotlin:mockito-kotlin:4.0.0"
//junit
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
//robolectric
testImplementation 'org.robolectric:robolectric:4.8'
//Google Truth
testImplementation "com.google.truth:truth:1.1.3"
//Jetpack Navigation
// Java language implementation
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
// Kotlin
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
// Feature module Support
implementation "androidx.navigation:navigation-dynamic-features-fragment:$nav_version"
// Testing Navigation
androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
// Jetpack Compose Integration
implementation "androidx.navigation:navigation-compose:$nav_version"
//material icons
implementation("androidx.compose.material:material-icons-extended:$compose_ui_version")
// 4. Android - Use Guava types
implementation("com.google.guava:guava:31.1-android")
// Coil - Imageloader
implementation("io.coil-kt:coil:2.2.2")
implementation("io.coil-kt:coil-compose:2.2.2")
// Room (DB)
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
// To use Kotlin annotation processing tool (kapt)
kapt "androidx.room:room-compiler:$room_version"
// optional - RxJava3 support for Room
implementation "androidx.room:room-rxjava3:$room_version"
// optional - Guava support for Room, including Optional and ListenableFuture
implementation "androidx.room:room-guava:$room_version"
// optional - Test helpers
testImplementation "androidx.room:room-testing:$room_version"
// optional - Paging 3 Integration
implementation "androidx.room:room-paging:$room_version"
}
// Allow references to generated code
kapt {
correctErrorTypes = true
}
buildscript {
ext {
compose_ui_version = '1.3.1'
hilt_di_version = '2.44'
retrofit_version = '2.9.0'
androidx_lifecycle_viewmodel_version = "2.5.1"
nav_version = "2.5.3"
material3_version= "1.0.1"
room_version = "2.4.3"
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
id("com.google.dagger.hilt.android") version "$hilt_di_version" apply false
}

ReadMe

Thanks for checking out my gist. This is a handy quick-start template for your Gradle files to setup an Android Compose app with the following features

Note Versions May Have Changed

App

  • Kotlin Support
  • Material 3 (Theming)
  • Retrofit 2 (Networking)
  • Android ViewModel Support
  • Hilt (Dependency Injection)
  • Jetpack Navigation
  • Coil (Imageloader)
  • Android Room (Database)
  • RxJava3

Testing

  • Mockito
  • Junit
  • Robolectric
  • Google Truth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment