Skip to content

Initial App Setup

Brandon Cano edited this page Jan 15, 2025 · 1 revision

Since most of my apps use the same set of dependencies, with the exception of a few differences here and there, this is the basic set of files to copy and paste over to get started.

These versions are from when I copied the file over, it's likely that they'll need to be updated.

local.properties

This isn't included here since its local but is needed in order to build the project.

libs.versions.toml

[versions]
# libraries
activity-compose = "1.9.3" # 
appcompat = "1.7.0" # 
bmcano = "1.5.2" # DATE_MODIFIED - this is our shared library
browser = "1.8.0" # 
compose = "1.7.6" # 
compose-bom = "2024.12.01" # 
coreKtx = "1.15.0" # 
gson = "2.10.1" # 
junit = "4.13.2" # 
material3 = "1.3.1" # 
mockk = "1.13.11" # 
navigation-compose = "2.8.5" # 
ostermiller = "1.07.00" # 
ui-test-junit4 = "1.7.6" # 
# gradle/language
agp = "8.8.0" # 
kotlin = "2.0.0" # 
ktlint = "11.3.1" # 

[libraries]
# androidx
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activity-compose" }
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
androidx-browser = { module = "androidx.browser:browser", version.ref = "browser" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
androidx-compose-ui-graphics = { group = "androidx.compose.ui", name ="ui-graphics" }
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "ui-test-junit4" }
androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "compose" }
androidx-compose-material-icons = { module = "androidx.compose.material:material-icons-extended", version.ref = "compose" }
androidx-compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "material3" }
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigation-compose" }
# com.google
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
# unit testing
junit = { module = "junit:junit", version.ref = "junit" }
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
# kotlin - Job: serialization for type safe navigation
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" } 
# misc
ostermiller-util = { module = "org.ostermiller:utils", version.ref = "ostermiller" } # Job: counts sigfigs 
bmcano-util = { module = "com.github.bmcano:android-shared-components", version.ref = "bmcano" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
jetbrains-kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
jetbrains-kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
gradle-ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }

Project-Level build.gradle.kts

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    alias(libs.plugins.android.application) apply false
    alias(libs.plugins.android.library) apply false
    alias(libs.plugins.jetbrains.kotlin) apply false
    alias(libs.plugins.gradle.ktlint)
}

settings.gradle.kts

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}

@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven {
            url = uri("https://jitpack.io")
        }
    }
}

rootProject.name = "{PROJECT_NAME}"
include(":app")

Module-Level (app) build.gradle.kts

plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.jetbrains.kotlin)
    alias(libs.plugins.jetbrains.kotlin.compose)
}

android {
    namespace = "com.brandoncano.{PACKAGE_NAME}"
    compileSdk = 35

    defaultConfig {
        applicationId = "com.brandoncano.{PACKAGE_NAME}"
        minSdk = 21
        targetSdk = 35
        versionCode = 1 // for 1.0.0
        versionName = "1.0.0"

        vectorDrawables {
            useSupportLibrary = true
        }
    }
    applicationVariants.configureEach {
        val suffix = if (buildType.name == "debug") ", DEBUG" else ""
        resValue("string", "version", "$versionName$suffix")
        resValue("string", "last_updated", "1/14/2025")
    }
    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = "17"
    }
    buildFeatures {
        compose = true
    }

    @Suppress("UnstableApiUsage")
    testOptions {
        unitTests.isReturnDefaultValues = true
    }
}

composeCompiler {
    enableStrongSkippingMode = true
}

dependencies {
    // androidx
    implementation(libs.androidx.appcompat)
    implementation(libs.androidx.browser)
    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.activity.compose)
    implementation(libs.androidx.navigation.compose)
    // androidx.compose.ui
    implementation(platform(libs.androidx.compose.bom))
    implementation(libs.androidx.compose.ui)
    implementation(libs.androidx.compose.ui.graphics)
    implementation(libs.androidx.compose.ui.tooling.preview)
    debugImplementation(libs.androidx.compose.ui.tooling)
    debugImplementation(libs.androidx.compose.ui.test.manifest)
    androidTestImplementation(libs.androidx.compose.ui.test.junit4)
    // androidx.compose
    implementation(libs.androidx.compose.runtime.livedata)
    implementation(libs.androidx.compose.material.icons)
    implementation(libs.androidx.compose.material3)
    // com.google
    implementation(libs.gson)
    // unit testing
    testImplementation(libs.mockk)
    testImplementation(libs.junit)
    // jetbrains
    implementation(libs.kotlinx.serialization.json) // Job: serialization for type safe navigation
    // external libraries
    implementation(libs.ostermiller.util) // Job: counts sigfigs
    implementation(libs.bmcano.util)
}

Clone this wiki locally