<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sehaj kahlon on Medium]]></title>
        <description><![CDATA[Stories by Sehaj kahlon on Medium]]></description>
        <link>https://medium.com/@sehajkahlon437?source=rss-718ce0ca0016------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mMJzCmTz2R7rlfbtLUyN7w.png</url>
            <title>Stories by Sehaj kahlon on Medium</title>
            <link>https://medium.com/@sehajkahlon437?source=rss-718ce0ca0016------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 01:42:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sehajkahlon437/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Gradle for Android Developers: A Visual Guide From Zero to Advanced]]></title>
            <link>https://medium.com/@sehajkahlon437/gradle-for-android-developers-a-visual-guide-from-zero-to-advanced-4392d04d1e3c?source=rss-718ce0ca0016------2</link>
            <guid isPermaLink="false">https://medium.com/p/4392d04d1e3c</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Sehaj kahlon]]></dc:creator>
            <pubDate>Sat, 03 Oct 2026 18:56:59 GMT</pubDate>
            <atom:updated>2026-10-03T18:56:59.159Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*22toVYAvDuhLKo9WgmjpRQ.png" /></figure><h3>A visual, from-the-ground-up guide to understanding Gradle, AGP, build variants, dependencies, build performance, and what actually happens when you build an APK.</h3><p>Most Android developers learn Gradle by accident.</p><p>You copy a line from Stack Overflow into build.gradle.kts, the red squiggle goes away, and you move on. A year later you&#39;re still copying lines, still not sure what implementation actually means, and still typing ./gradlew clean whenever something feels off.</p><p>This article is the whiteboard session I wish I’d had. We start from zero — no assumed knowledge — and end at the things build engineers argue about. Every concept is built from a picture first and a definition second.</p><p>It’s long. It’s meant to be. Bookmark it.</p><h3>Part 0 — Forget the definitions. Look at this picture.</h3><p>You wrote an Android app. You have some Kotlin files, some XML layouts, some images, and you used three libraries someone else wrote.</p><p>Your phone cannot run any of that. Your phone runs exactly one thing: an .apk file.</p><p>So somebody has to do this:</p><pre>YOUR STUFF                          WHAT THE PHONE NEEDS<br>  ----------                          --------------------<br>  MainActivity.kt      ─┐<br>  LoginViewModel.kt     │<br>  activity_main.xml     │<br>  strings.xml           ├──►  ???  ──►   app-release.apk<br>  ic_logo.png           │              (one signed zip file)<br>  AndroidManifest.xml   │<br>  retrofit-2.11.0.jar  ─┘</pre><p>That ??? box is roughly twenty-five separate steps, in a strict order:</p><pre>1. download retrofit-2.11.0.jar from the internet<br> 2. ...and everything retrofit itself needs (okhttp, okio...)<br> 3. compile every XML resource into binary form      (AAPT2)<br> 4. generate the R class so code can say R.id.button<br> 5. merge YOUR manifest with the manifest of all 3 libraries<br> 6. run annotation processors (Hilt/Room generate code)<br> 7. compile Kotlin -&gt; .class files (JVM bytecode)<br> 8. shrink and obfuscate unused code                 (R8)<br> 9. convert .class -&gt; .dex (Android&#39;s bytecode)      (D8)<br>10. zip everything together<br>11. sign the zip with your private key<br>12. align the zip on 4-byte boundaries               (zipalign)</pre><p>Now do that by hand. Every time you change one line. For two build types times three flavors. For four hundred modules.</p><p><strong>Gradle is the thing that does the </strong><strong>??? box for you.</strong></p><p>That’s the whole idea. Everything below is detail.</p><h3>Part 1 — Taking apart “Gradle is a build automation tool”</h3><p>Each word in that sentence is doing real work.</p><p>“<strong>Build</strong>” — turning <em>source</em> (what humans write) into an <em>artifact</em> (what machines run). On Android the artifact is an .apk or an .aab for an app, or an .aar for a library module.</p><p>“<strong>Automation</strong>” — you describe <em>what you want</em>, not <em>how to do it</em>. You never type d8 --min-api 24 .... You type ./gradlew assembleDebug.</p><p>“<strong>Tool</strong>” — Gradle is not part of Android. It’s a general-purpose build tool. People build Java servers, Kotlin backends, C++ and Scala with it. Android just happens to be its largest user.</p><h4>The split that most developers never learn</h4><pre>┌───────────────────────────────────────────────────────┐<br>│  GRADLE                                               │<br>│  &quot;I know how to run tasks in the right order,         │<br>│   download dependencies, and cache results.&quot;          │<br>│  Knows NOTHING about Android. Zero.                   │<br>│                                                       │<br>│   ┌─────────────────────────────────────────────┐     │<br>│   │  ANDROID GRADLE PLUGIN  (AGP)               │     │<br>│   │  made by Google                             │     │<br>│   │  &quot;I know what an APK is, what minSdk means, │     │<br>│   │   how to run AAPT2, D8, R8, and how to sign&quot;│     │<br>│   └─────────────────────────────────────────────┘     │<br>└───────────────────────────────────────────────────────┘</pre><p>Gradle is the <strong>engine</strong>. AGP is the <strong>Android knowledge</strong> plugged into that engine.</p><p>This is why you write id(&quot;com.android.application&quot;) at the top of your app&#39;s build file. That one line is what teaches a generic build tool what &quot;Android&quot; even means. Remove it and Gradle will cheerfully build nothing Android-shaped at all.</p><p><strong>Immediate consequence:</strong> the Gradle version and the AGP version are two <em>different</em> numbers, and they must be compatible with each other. A large fraction of all “I opened an old project and it exploded” problems are exactly this mismatch.</p><h3>Part 2 — Where the Gradle files actually live</h3><p>A normal Android project:</p><pre>MyApp/                                 &lt;-- &quot;root project&quot;<br>│<br>├── gradlew                            executable script (Mac/Linux)<br>├── gradlew.bat                        executable script (Windows)<br>├── gradle/<br>│   ├── wrapper/<br>│   │   ├── gradle-wrapper.properties  &lt;-- WHICH Gradle version<br>│   │   └── gradle-wrapper.jar         &lt;-- tiny downloader program<br>│   └── libs.versions.toml             &lt;-- version catalog<br>│<br>├── settings.gradle.kts                &lt;-- WHICH modules exist<br>├── build.gradle.kts                   &lt;-- ROOT build file (shared config)<br>├── gradle.properties                  &lt;-- JVM memory + global flags<br>├── local.properties                   &lt;-- YOUR machine only, never committed<br>│<br>├── app/                               &lt;-- a MODULE<br>│   ├── build.gradle.kts               &lt;-- MODULE build file (the important one)<br>│   ├── proguard-rules.pro<br>│   └── src/<br>│       ├── main/java/...<br>│       ├── main/res/...<br>│       ├── main/AndroidManifest.xml<br>│       ├── test/java/...              unit tests (run on your laptop JVM)<br>│       └── androidTest/java/...       instrumented tests (run on a device)<br>│<br>└── core-network/                      &lt;-- another MODULE<br>    ├── build.gradle.kts<br>    └── src/main/java/...</pre><p>Look at the shape of it:</p><pre>ROOT PROJECT  (MyApp)<br>        - settings.gradle.kts   &quot;who are my children?&quot;<br>        - build.gradle.kts      &quot;rules for all my children&quot;<br>              │<br>        ┌─────┴─────────────┐<br>        ▼                   ▼<br>    :app                :core-network<br>    build.gradle.kts    build.gradle.kts</pre><p><strong>Every module has its own </strong><strong>build.gradle.kts</strong>. <strong>The root has one too, but its job is completely different</strong>. That&#39;s the detail that confuses everyone at first. Let&#39;s do each file one at a time, in the order Gradle reads them.</p><h3>Part 3 — File by file</h3><h3>3.1 <strong>gradlew</strong> — the Gradle Wrapper</h3><p>Type gradle build in a terminal and you use <strong>whatever Gradle happens to be installed on that machine</strong>. You have 8.5. Your teammate has 7.2. CI has 6.9.</p><p>Three people, three different builds, three different bugs. This has cost real teams real days.</p><p>The wrapper fixes it:</p><pre>You type:        ./gradlew assembleDebug<br>                      │<br>                      ▼<br>          gradlew (a shell script)<br>                      │<br>                      ▼<br>      reads gradle/wrapper/gradle-wrapper.properties<br>                      │<br>                      ▼<br>      &quot;distributionUrl = ...gradle-8.13-bin.zip&quot;<br>                      │<br>        ┌─────────────┴──────────────┐<br>        ▼                            ▼<br>  Already downloaded?          Not downloaded?<br>  use ~/.gradle/wrapper/...    download it, unzip, cache it<br>        └─────────────┬──────────────┘<br>                      ▼<br>          run the build with EXACTLY 8.13</pre><p>The file itself is four lines:</p><pre>distributionBase=GRADLE_USER_HOME<br>distributionPath=wrapper/dists<br>distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip<br>zipStoreBase=GRADLE_USER_HOME</pre><p>Pinned to one version. Every engineer, every CI machine, no debate.</p><p>In larger organisations you’ll often see that URL pointing at an internal artifact mirror instead of services.gradle.org. Two reasons: builds don&#39;t break when the public internet does, and nobody can slip a malicious distribution in.</p><p><strong>Rules, learned the hard way:</strong></p><ul><li>Always run ./gradlew, never bare gradle.</li><li>gradle-wrapper.jar must be committed to git. It&#39;s about 60 KB. People add *.jar to .gitignore, accidentally delete it, and CI dies with Could not find or load main class org.gradle.wrapper.GradleWrapperMain.</li><li>Upgrade with ./gradlew wrapper --gradle-version 8.13, never by hand-editing. Hand-editing skips updating the checksum and the scripts.</li></ul><h3>3.2 settings.gradle.kts — the guest list</h3><p>This is the first file Gradle reads. Until it does, Gradle doesn’t know your project has modules at all.</p><pre>rootProject.name = &quot;MyApp&quot;<br><br>include(&quot;:app&quot;)<br>include(&quot;:core-network&quot;)<br>include(&quot;:feature-login&quot;)</pre><p>include(&quot;:app&quot;) means: &quot;there&#39;s a folder called app, treat it as a module, and its Gradle name is :app.&quot;</p><p>The colon is a <strong>path separator</strong>, like /. So :features:login means the folder features/login.</p><h4>The folder name and the module name are two different thing</h4><p>You can point a module anywhere:</p><pre>include(&quot;:discovery&quot;)<br>project(&quot;:discovery&quot;).projectDir = file(&quot;features/discovery/impl&quot;)</pre><p>Teams with large codebases lean on this heavily to keep a readable Gradle namespace over a deep physical folder structure. Which brings us to a genuinely interesting trick.</p><h4>Enforcing architecture in the build</h4><p>settings.gradle.kts is executable Kotlin, so you can validate module names as you register them:</p><pre>fun includeFrameworkModule(name: String) {<br>    require(name.startsWith(&quot;framework-&quot;)) {<br>        &quot;Framework-layer modules must be named framework-*, got: $name&quot;<br>    }<br>    include(&quot;:$name&quot;)<br>    project(&quot;:$name&quot;).projectDir = file(&quot;framework-layer/$name&quot;)<br>}</pre><p>Now a module that violates the layering convention cannot be added to the build. The build fails before a single line of code compiles.</p><p>This is one of the highest-leverage ideas in this whole article, so let me say it plainly:</p><blockquote><em>A dependency rule that only lives in a wiki will be violated within a month. A dependency rule enforced by the build cannot be violated at all.</em></blockquote><h4>The other job: where dependencies come from</h4><pre>pluginManagement {<br>    repositories {<br>        gradlePluginPortal()<br>        google()<br>        mavenCentral()<br>    }<br>}<br>dependencyResolutionManagement {<br>    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)<br>    repositories {<br>        google()<br>        mavenCentral()<br>    }<br>}</pre><ul><li>pluginManagement { } — where to find plugins (AGP, Kotlin, Hilt).</li><li>dependencyResolutionManagement { } — where to find libraries (Retrofit, Coil).</li><li>FAIL_ON_PROJECT_REPOS — &quot;no individual module may sneak in its own repository.&quot; That&#39;s a security control, not a style preference.</li></ul><blockquote><em>Take this seriously. Gradle asks repositories in declaration order. If an untrusted repo comes first, a package named </em><em>com.mycompany.internal-auth published by an attacker on a public repository can be served </em>instead of<em> yours. This is called a dependency-confusion attack, and it has hit real companies for real money. Put your internal repository first, or use </em><em>exclusiveContent / </em><em>includeGroup filters to pin exactly which groups may come from where. And never put </em><em>mavenLocal() in a shared build.</em></blockquote><h3>3.3 Root build.gradle.kts — the house rules</h3><p>New engineers try to put dependencies here. Wrong instinct. The root build file builds nothing. It has two jobs:</p><ol><li>Declare which plugins <em>exist</em> for the whole build.</li><li>Configure things shared by every module.</li></ol><pre>plugins {<br>    id(&quot;com.android.application&quot;) version &quot;8.5.0&quot; apply false<br>    id(&quot;com.android.library&quot;)     version &quot;8.5.0&quot; apply false<br>    id(&quot;org.jetbrains.kotlin.android&quot;) version &quot;1.9.24&quot; apply false<br>}</pre><p>apply false reads as: <em>&quot;download this plugin and put it on the classpath, but don&#39;t switch it on here — my children will switch it on.&quot;</em></p><p>Why? The root project isn’t an Android app; applying com.android.application to it would be nonsense. But if you don&#39;t declare the version here, every module repeats it, and the day they drift apart you get a genuinely horrible error message.</p><p>Real root build files also do things like this, which is worth stealing:</p><pre>val useNewQualityPlugin =<br>    (project.properties[&quot;useNewQualityPlugin&quot;] as? String)?.toBoolean() ?: true<br>if (useNewQualityPlugin) {<br>    apply(plugin = &quot;com.example.quality&quot;)<br>} else {<br>    apply(plugin = &quot;org.sonarqube&quot;)<br>}</pre><p>A <strong>feature flag inside the build script,</strong> flippable from the command line with -PuseNewQualityPlugin=false. That&#39;s how you migrate a large build from one tool to another without a big-bang risk. Build code is code. It deserves feature flags, comments, and review.</p><h3>3.4 Module build.gradle.kts — where you&#39;ll spend 95% of your time</h3><p>Here’s a complete one. We’ll read it back line by line.</p><pre>plugins {<br>    id(&quot;com.android.application&quot;)<br>    id(&quot;org.jetbrains.kotlin.android&quot;)<br>    id(&quot;com.google.devtools.ksp&quot;)<br>    id(&quot;dagger.hilt.android.plugin&quot;)<br>}<br>android {<br>    namespace = &quot;com.example.myapp&quot;<br>    compileSdk = 34<br>defaultConfig {<br>        applicationId = &quot;com.example.myapp&quot;<br>        minSdk = 24<br>        targetSdk = 34<br>        versionCode = 42<br>        versionName = &quot;3.1.0&quot;<br>        testInstrumentationRunner = &quot;androidx.test.runner.AndroidJUnitRunner&quot;<br>    }<br>buildTypes {<br>        debug {<br>            isMinifyEnabled = false<br>            applicationIdSuffix = &quot;.debug&quot;<br>        }<br>        release {<br>            isMinifyEnabled = true<br>            isShrinkResources = true<br>            proguardFiles(<br>                getDefaultProguardFile(&quot;proguard-android-optimize.txt&quot;),<br>                &quot;proguard-rules.pro&quot;<br>            )<br>            signingConfig = signingConfigs.getByName(&quot;release&quot;)<br>        }<br>    }<br>flavorDimensions += &quot;environment&quot;<br>    productFlavors {<br>        create(&quot;stage&quot;)      { buildConfigField(&quot;String&quot;, &quot;BASE_URL&quot;, &quot;\&quot;https://stage.api.com\&quot;&quot;) }<br>        create(&quot;production&quot;) { buildConfigField(&quot;String&quot;, &quot;BASE_URL&quot;, &quot;\&quot;https://api.com\&quot;&quot;) }<br>    }buildFeatures {<br>        viewBinding = true<br>        buildConfig = true<br>    }    compileOptions {<br>        sourceCompatibility = JavaVersion.VERSION_17<br>        targetCompatibility = JavaVersion.VERSION_17<br>    }<br>    kotlinOptions { jvmTarget = &quot;17&quot; }<br>}dependencies {<br>    implementation(project(&quot;:core-network&quot;))<br>    implementation(&quot;androidx.core:core-ktx:1.13.1&quot;)<br>    implementation(&quot;com.squareup.retrofit2:retrofit:2.11.0&quot;)<br>    ksp(&quot;com.google.dagger:hilt-compiler:2.51&quot;)<br>    testImplementation(&quot;junit:junit:4.13.2&quot;)<br>    androidTestImplementation(&quot;androidx.test.ext:junit:1.1.5&quot;)<br>}</pre><h4>plugins { }</h4><p>com.android.application means &quot;this module produces an APK.&quot; com.android.library means &quot;this module produces an .aar for other modules to consume.&quot;</p><p><strong>An app module is the only kind that can be installed</strong>. Library modules cannot.</p><h4>namespace</h4><p>The package used to generate the R and BuildConfig classes. Every module needs a unique one. Two modules sharing a namespace collide, and you get baffling &quot;unresolved reference: R&quot; errors.</p><h4>compileSdk, minSdk, targetSdk — the three that confuse everyone</h4><p>compileSdk = 34 — <em>&quot;Which version of the Android API am I allowed to write code against?&quot;</em> You can call APIs introduced in Android 14. This does not change runtime behaviour. Always use the latest stable.</p><p>minSdk = 24 — <em>&quot;The oldest Android version that may install my app.&quot;</em> A phone on API 23 literally cannot see your app in the Play Store. Lower = more users and more compatibility pain. Higher = fewer users and cleaner code.</p><p>If you call an API-31-only method with minSdk = 24, Lint fails the build unless you guard it:</p><pre>if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.S) { /* ... */ }</pre><p>targetSdk = 34 — the hard one. <em>&quot;Which version&#39;s behaviour changes have I tested and accepted?&quot;</em></p><p>Android keeps its promises to old apps. If you declare targetSdk = 28, the OS thinks &quot;this was written before scoped storage existed, let me keep the old behaviour.&quot; The moment you bump to 34, the OS says &quot;fine, you claim to be modern&quot; and switches on scoped storage, the runtime notification permission, foreground-service types, exact-alarm restrictions, and more.</p><pre>compileSdk  = what you can SEE     (compile time)<br>minSdk      = who can INSTALL      (install time)<br>targetSdk   = what rules APPLY     (run time)</pre><p>Bumping targetSdk is never &quot;just a number change.&quot; Google mandates a minimum every year to stay on Play. I&#39;ve watched a team bump it the week before a release and discover that background location had silently stopped working for a large slice of users. Bump it on day one of a cycle, never on day thirty.</p><h4>versionCode / versionName</h4><p>versionCode is an integer Play uses to decide &quot;is this newer?&quot; It must strictly increase. versionName is the human-readable string. Play doesn&#39;t care about it.</p><h4>buildTypes { } — how it&#39;s built</h4><p>Debug: fast, debuggable, no shrinking. Release: shrunk, obfuscated, signed.</p><p>applicationIdSuffix = &quot;.debug&quot; is one of the highest-value single lines in all of Android. It changes the debug build&#39;s package to com.example.myapp.debug, so debug and release can be installed side by side on one phone. Without it, installing a debug build wipes your production app and all its data. I have seen a QA team lose test data to this for three years because nobody added one line.</p><h4>productFlavors { } — what is built</h4><p>Same code, different identity: free vs paid, stage vs prod, white-label client A vs client B.</p><h4>Variants — the multiplication that surprises everyone</h4><pre>buildTypes:      debug        release<br>                        ┌──────────────────────────┐<br>flavors:    stage       │ stageDebug   stageRelease│<br>            production  │ prodDebug    prodRelease │<br>                        └──────────────────────────┘</pre><p>variant = flavor × buildType. Two by two is four. Add a second flavor dimension with three values and you have twelve. Every Gradle task is generated <em>per variant</em>: assembleStageDebug, testProdReleaseUnitTest, and so on.</p><p>Once you see this, long task names stop being intimidating. assembleAppProductionDebug is just assemble + the flavors App and Production + the build type Debug. It&#39;s string concatenation, not magic.</p><h4>Source sets — the free superpower nobody teaches juniors</h4><p>Every variant automatically gets its own source folder:</p><pre>src/main/java/...           always included<br>src/debug/java/...          only in debug builds<br>src/release/java/...        only in release builds<br>src/stage/java/...          only in the stage flavor<br>src/stageDebug/java/...     only in stageDebug</pre><p>So you can put a real AnalyticsLogger in src/release/ and a no-op one in src/debug/ — same class name, same package — and the right one gets compiled in. No if (BuildConfig.DEBUG) scattered through your codebase.</p><p>More importantly, debug-only code is then physically absent from the release APK.</p><blockquote><em>I once reviewed an app where a QA “skip OTP” toggle lived behind </em><em>if (BuildConfig.DEBUG). The class was still in the release APK. Someone found it with a decompiler in an afternoon. </em><em>BuildConfig.DEBUG removes the call, not the code — unless R8 happens to prove it&#39;s unreachable. Source sets remove the code. For anything security-sensitive, use source sets.</em></blockquote><h4>buildFeatures { }</h4><p>Switches for code generation: viewBinding, dataBinding, compose, buildConfig. Each one costs build time in every module it&#39;s enabled in. Turn on only what that module uses. In AGP 8+, buildConfig is off by default — which is why large legacy codebases carry android.defaults.buildfeatures.buildconfig=true in gradle.properties as a compatibility switch.</p><h4>compileOptions / kotlinOptions</h4><p>Java and Kotlin must target the same JVM bytecode level. A mismatch gives you the classic:</p><pre>Execution failed for task &#39;:app:compileDebugKotlin&#39;<br>&gt; Inconsistent JVM-target compatibility detected... Java 17 vs Kotlin 1.8</pre><p>Set both. Same number. Every time.</p><h4>dependencies { } — and the word that actually matters</h4><pre>implementation(&quot;com.squareup.retrofit2:retrofit:2.11.0&quot;)<br>//              ▲ group            ▲ artifact  ▲ version</pre><p>That triple is called GAV coordinates. Gradle turns it into a URL against your repositories { }, downloads a .jar/.aar plus a metadata file describing <em>its</em> dependencies, and pulls those too — transitive dependencies.</p><pre>you ask for:  retrofit:2.11.0<br>Gradle pulls: retrofit<br>                └── okhttp<br>                      └── okio<br>                            └── kotlin-stdlib</pre><p>Run ./gradlew :app:dependencies and you&#39;ll see this tree for real. Do it today. It&#39;s the single most useful Gradle command for debugging.</p><h4>implementation vs api — the question every senior asks in interviews</h4><pre>  ┌─────────────┐        ┌──────────────┐       ┌────────────┐<br>  │   :app      │ ─────► │  :feature    │ ─────►│  retrofit  │<br>  └─────────────┘        └──────────────┘       └────────────┘<br><br>:feature uses  implementation(retrofit)<br>   → :app CANNOT see Retrofit classes.<br>   → change the retrofit version, ONLY :feature recompiles.<br><br>:feature uses  api(retrofit)<br>   → :app CAN see Retrofit classes.<br>   → change retrofit, and :feature AND :app AND everything above recompiles.</pre><p>api leaks the dependency upward through your entire module graph. In a large app, one careless api can turn a one-line change into a twenty-minute rebuild.</p><p>Default to implementation. Use api only when your public API signature literally exposes that type — for example, when a public function returns an okhttp3.Response.</p><p>The rest of the configurations:</p><ul><li>compileOnly — needed to compile, not shipped (annotation-only artifacts).</li><li>runtimeOnly — shipped, not compiled against (a JDBC driver, a logging backend).</li><li>kapt / ksp — annotation processors. They don&#39;t ship; they <em>generate code</em> at build time. KSP is the Kotlin-native successor and is roughly twice as fast. Migrate when you can — kapt forces Kotlin to generate Java stubs for the whole module, which is slow and is being wound down.</li><li>testImplementation — unit tests only (src/test, runs on your laptop JVM).</li><li>androidTestImplementation — instrumented tests only (src/androidTest, runs on a device).</li><li>debugImplementation — debug variants only. This is where LeakCanary and network inspectors belong. Never declare a debug tool with implementation, or you ship a memory profiler and a traffic sniffer to production.</li><li>implementation(project(&quot;:core-network&quot;)) — depend on another module in the same build.</li></ul><h4>Version conflicts</h4><p>Two libraries want different versions of okhttp. Gradle’s default: pick the highest. Usually fine. Occasionally catastrophic — a major version removed a method, so you get a NoSuchMethodError at <em>runtime</em>. Your build is green and your app crashes in production.</p><p>Fixes, gentlest to strongest:</p><pre>// 1. BOM — one source of truth for a whole family<br>implementation(platform(&quot;com.squareup.okhttp3:okhttp-bom:4.12.0&quot;))<br>implementation(&quot;com.squareup.okhttp3:okhttp&quot;)     // no version needed<br><br>// 2. Force a version<br>implementation(&quot;com.squareup.okhttp3:okhttp:4.12.0!!&quot;)  <br><br>// strict// 3. Drop a bad transitive<br>implementation(&quot;some:lib:1.0&quot;) { exclude(group = &quot;org.json&quot;) }</pre><p>At scale, teams extract option 2 into a custom plugin that pins versions for the entire organisation, so hundreds of modules can’t drift apart.</p><h3>3.5 gradle.properties — the machine dial</h3><pre>org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8</pre><p>Gradle runs on the JVM; this is its heap. If you see Java heap space or GC overhead limit exceeded, this is the dial. If your machine starts swapping, this is also the dial — turn it <em>down</em>.</p><pre>kotlin.daemon.jvmargs=-Xmx4g -XX:+UseG1GC</pre><p><strong>The Kotlin compiler gets its own separate JVM</strong>. Developers raise org.gradle.jvmargs and wonder why Kotlin still runs out of memory. Two daemons, two heaps.</p><pre>org.gradle.daemon=true</pre><p>The Gradle Daemon is a long-lived background JVM. Starting a JVM and warming its JIT takes seconds. The daemon survives between builds, so build #2 is much faster than build #1.</p><pre>org.gradle.parallel=true</pre><p>Build independent modules on different threads simultaneously. Safe only when modules don’t mutate each other’s state.</p><pre>org.gradle.caching=true<br>org.gradle.configuration-cache=true<br>org.gradle.configureondemand=true<br>org.gradle.workers.max=8</pre><p>Build cache, configuration cache (both covered below), configure only the modules needed for the requested task, and a cap on parallel workers.</p><pre>android.useAndroidX=true<br>android.enableJetifier=true</pre><p>AndroidX is the modern support library. Jetifier rewrites old android.support.* bytecode inside third-party jars on the fly. It is slow and it is a migration crutch. enableJetifier=true today means some dependency in your tree is still pre-AndroidX. Finding and removing it is a real, measurable build-speed win — ./gradlew checkJetifier tells you who the culprit is.</p><pre>android.nonTransitiveRClass=true</pre><p>When true, module A can only use R.string.x that A itself declared, not ones inherited from B. It makes R classes far smaller and builds faster, but it&#39;s a breaking change requiring code edits everywhere. Large codebases often sit on false mid-migration. That&#39;s normal; just don&#39;t forget about it.</p><pre>android.enableR8.fullMode=false</pre><p>R8 full mode optimises harder but breaks reflection-based libraries more often. Turning it off is a stability choice, not a mistake.</p><p>The rule: gradle.properties at the project root is committed and applies to everyone. ~/.gradle/gradle.properties is yours alone and overrides it — that&#39;s where <em>your</em> laptop&#39;s memory settings and <em>your</em> credentials go, so you never commit them.</p><h3>3.6 local.properties — never commit this</h3><pre>sdk.dir=/Users/yourname/Library/Android/sdk</pre><p>Machine-specific paths. It’s gitignored because your teammate’s SDK isn’t at your path.</p><blockquote><em>Security: people put </em><em>API_KEY=... and keystore passwords here because &quot;it&#39;s gitignored.&quot; That works until someone zips the folder, or </em><em>.gitignore gets edited, or you share a workspace. Secrets belong in environment variables or a secret manager injected by CI — not in a file sitting next to your code.</em></blockquote><h3>3.7 libs.versions.toml — the version catalog</h3><p>The problem: four hundred modules, and retrofit:2.9.0 is typed into a hundred and eighty of them. Upgrade day means a hundred and eighty edits.</p><p>The fix, in gradle/libs.versions.toml:</p><pre>[versions]<br>retrofit = &quot;2.11.0&quot;<br>kotlin   = &quot;1.9.24&quot;<br>[libraries]<br>retrofit      = { module = &quot;com.squareup.retrofit2:retrofit&quot;, version.ref = &quot;retrofit&quot; }<br>retrofit-gson = { module = &quot;com.squareup.retrofit2:converter-gson&quot;, version.ref = &quot;retrofit&quot; }<br>[plugins]<br>kotlin-android = { id = &quot;org.jetbrains.kotlin.android&quot;, version.ref = &quot;kotlin&quot; }<br>[bundles]<br>network = [&quot;retrofit&quot;, &quot;retrofit-gson&quot;]</pre><p>Then, in any module:</p><pre>dependencies {<br>    implementation(libs.retrofit)<br>    implementation(libs.bundles.network)   // both at once<br>}</pre><p>Typed, autocompleted, one place to upgrade. Teams often run two catalogs — one for third-party libraries and one for their own internal libraries — because they have different upgrade cadences, different owners, and different risk profiles.</p><p>Why does this matter beyond convenience? Because when a CVE drops for a networking library, “upgrade everywhere” should be a one-line merge request, not a sprint.</p><h3>3.8 buildSrc/ and build-logic/ — where the build becomes real engineering</h3><p>Suppose forty library modules all contain the same thirty lines: same compileSdk, same Java 17, same test setup. Copy-paste forty times. Now change one thing.</p><p>buildSrc is a special folder that Gradle compiles first and puts on the classpath of every build script. You write real Kotlin in it — classes, helpers, and convention plugins:</p><pre>// buildSrc/src/main/kotlin/myapp.android.library.gradle.kts<br>plugins {<br>    id(&quot;com.android.library&quot;)<br>    id(&quot;org.jetbrains.kotlin.android&quot;)<br>}<br>android {<br>    compileSdk = 34<br>    defaultConfig { minSdk = 24 }<br>    compileOptions {<br>        sourceCompatibility = JavaVersion.VERSION_17<br>        targetCompatibility = JavaVersion.VERSION_17<br>    }<br>}</pre><p>And a module’s entire build file becomes:</p><pre>plugins { id(&quot;myapp.android.library&quot;) }<br>dependencies { implementation(libs.retrofit) }</pre><p>Three lines instead of thirty.</p><p>This is the clearest marker of a senior versus a junior Android build. Juniors copy-paste build files. Seniors write convention plugins.</p><p>The buildSrc tax: any change to buildSrc invalidates the whole build&#39;s configuration and recompiles everything. On a large repo that hurts, which is why bigger teams move the same logic into a build-logic included build (a composite build) instead — identical idea, much better incrementality.</p><h3>Part 4 — Groovy DSL vs Kotlin DSL</h3><p>You’ll see build.gradle (Groovy) in old tutorials and build.gradle.kts (Kotlin) in new ones. Same concepts, different syntax:</p><pre>// Groovy — build.gradle<br>android {<br>    compileSdk 34<br>    defaultConfig { minSdk 24 }<br>}<br>dependencies {<br>    implementation &#39;androidx.core:core-ktx:1.13.1&#39;<br>}</pre><pre>// Kotlin — build.gradle.kts<br>android {<br>    compileSdk = 34<br>    defaultConfig { minSdk = 24 }<br>}<br>dependencies {<br>    implementation(&quot;androidx.core:core-ktx:1.13.1&quot;)<br>}</pre><p>Kotlin DSL: = for assignment, parentheses for calls, double quotes for strings, and — the real win — autocomplete and compile-time errors in the IDE. Groovy is looser, configures marginally faster, and turns every typo into a runtime failure with a terrible message.</p><p>Use .kts for anything new.</p><h3>Part 5 — The three phases. This is the architect-level concept.</h3><p>Every Gradle build runs three phases, always, in this order. Understand this diagram and you’re ahead of most working Android developers.</p><pre>./gradlew :app:assembleDebug<br>            │<br>   ┌────────▼─────────────────────────────────────────────┐<br>   │ 1. INITIALIZATION                                    │<br>   │    reads settings.gradle.kts                         │<br>   │    decides which modules are in the build            │<br>   │    creates a Project object per module               │<br>   └────────┬─────────────────────────────────────────────┘<br>            │<br>   ┌────────▼─────────────────────────────────────────────┐<br>   │ 2. CONFIGURATION                                     │<br>   │    runs EVERY build.gradle.kts, top to bottom        │<br>   │    EVERY module. Even ones you don&#39;t need.           │<br>   │    Result: a task graph. NO task has run yet.        │<br>   └────────┬─────────────────────────────────────────────┘<br>            │<br>   ┌────────▼─────────────────────────────────────────────┐<br>   │ 3. EXECUTION                                         │<br>   │    walks the graph, runs only the needed tasks       │<br>   │    skips tasks that are UP-TO-DATE or FROM-CACHE     │<br>   └──────────────────────────────────────────────────────┘</pre><h3>Why this matters, with a concrete disaster</h3><pre>android {<br>    defaultConfig {<br>        versionName = &quot;git rev-parse --short HEAD&quot;.runCommand()   // 💀<br>    }<br>}</pre><p>That line runs during the configuration phase. It spawns a git subprocess on every single build, in every module that has it — even when you run ./gradlew help. Put it in fifty modules and you&#39;ve added fifteen seconds to literally every command you type.</p><p>Worse, it makes the build non-cacheable, because the result changes based on something Gradle can’t track.</p><p>The correct shape: configuration should only <em>describe</em>. Work happens during execution, inside a task, with declared inputs and outputs.</p><h3>Configuration cache</h3><p>Since the configuration phase usually produces the same task graph, Gradle can serialise it and skip the phase entirely:</p><pre>org.gradle.configuration-cache=true</pre><p>On a large multi-module build this is the difference between about sixty seconds and about two seconds before any real work starts.</p><p>The price: your build scripts must be configuration-cache compatible. No reading System.getenv() at configuration time without wrapping it in a provider. No capturing the Project object inside a task action. No arbitrary I/O.</p><p>In real codebases you’ll find comments like // plugin disabled: leaks Project graph via shutdown hook in daemon. Somebody hit that wall and left a note. Those comments are worth more than a page of documentation.</p><h3>Part 6 — Tasks, and why your build is (or isn’t) fast</h3><h3>What a task is</h3><p>A task is a named unit of work with declared inputs and outputs.</p><pre>task :app:compileDebugKotlin<br>    inputs : all .kt files, the classpath, the compiler version, kotlinOptions<br>    outputs: build/tmp/kotlin-classes/debug/**/*.class</pre><p>That’s it. Everything else follows from that one sentence.</p><h3>Task dependencies form a graph</h3><pre>assembleDebug<br>        │<br>   packageDebug<br>        │<br>   ┌────┴──────────────┬───────────────────┐<br>   │                   │                   │<br>dexBuilderDebug   processDebugResources  mergeDebugAssets<br>   │                   │<br>compileDebugKotlin  mergeDebugResources<br>   │<br>generateDebugBuildConfig</pre><p>You ask for assembleDebug; Gradle works out everything underneath. You never specify order by hand.</p><h3>Up-to-date checks (incremental build)</h3><p>Before running a task, Gradle hashes its inputs and compares them to last time.</p><pre>Build 1:  :app:compileDebugKotlin             (ran, 8s)<br>Build 2:  :app:compileDebugKotlin UP-TO-DATE  (0s — nothing changed)</pre><p>This is why the second build is fast. It’s also why ./gradlew clean is almost always the wrong instinct — clean deletes exactly the information that makes builds fast.</p><p>“Try a clean build” is folk medicine. If a clean build fixes your problem, you have a <em>real</em> bug: some task has wrong or missing input/output declarations. Find it instead of ritualising around it.</p><h3>Build cache — a different thing</h3><pre>INCREMENTAL / UP-TO-DATE   &quot;I did this exact work last time, on this machine,<br>                            and the output is still sitting there.&quot;<br>BUILD CACHE                &quot;SOMEONE, somewhere, at some point, did this exact<br>                            work. Here is the output. Don&#39;t redo it.&quot;</pre><p>With a remote build cache, CI populates it and your laptop downloads results for modules you never touched. Switching branches becomes cheap. On a large repo, a remote cache is the difference between a three-minute and a thirty-minute build.</p><p>For a task to be cacheable it must be deterministic: same inputs, same outputs, always. Timestamps, absolute paths, and random values in outputs all break it.</p><h3>Commands worth memorising today</h3><pre>./gradlew tasks                         # what can I even run?<br>./gradlew :app:dependencies             # full dependency tree<br>./gradlew :app:dependencyInsight --dependency okhttp   # WHO pulled this in?<br>./gradlew assembleDebug --scan          # full build report, shareable URL<br>./gradlew assembleDebug --dry-run       # which tasks WOULD run<br>./gradlew assembleDebug --info          # why was each task not up-to-date?<br>./gradlew --stop                        # kill the daemons<br>./gradlew assembleDebug --offline       # no network; fails if deps missing</pre><p>dependencyInsight is the one that answers &quot;where on earth is this ancient library coming from.&quot; Learn it.</p><h3>Part 7 — What “Gradle Sync” actually means</h3><p>This is the question most candidates can’t answer, and it’s easy once you know the phases.</p><p>Android Studio is not a build tool. It’s an editor that talks to Gradle.</p><p>When you open a project, Studio needs things only Gradle knows:</p><pre>Android Studio                         Gradle<br>  --------------                         ------<br>  &quot;What modules exist?&quot;          ─────►  runs INITIALIZATION<br>  &quot;What are their source dirs?&quot;  ─────►  runs CONFIGURATION<br>  &quot;What&#39;s on the classpath?&quot;     ─────►  resolves dependencies<br>  &quot;What variants exist?&quot;         ─────►  asks AGP<br>  &quot;Where&#39;s the generated code?&quot;  ─────►<br>                                 ◄─────  a model of the whole project<br>  builds its index, enables<br>  autocomplete, red squiggles,<br>  the Run button, the variant dropdown</pre><p>Gradle Sync = phases 1 and 2 only, run for the IDE’s benefit. No compilation. No APK. It happens over something called the Gradle Tooling API.</p><p>So:</p><ul><li>Why does adding a dependency require a sync? The classpath changed and the IDE’s index is stale. Without a sync you get red squiggles on code that would compile perfectly.</li><li>Why is sync slow in a big repo? Because the configuration phase is expensive across hundreds of modules. Newer Gradle versions can parallelise sync (org.gradle.tooling.parallel=true) for exactly this reason.</li><li>“Sync succeeded but build failed” — completely normal, and now you know why. Sync never ran the execution phase. Configuration was fine; compilation wasn’t.</li><li>“Build succeeded but the IDE shows red errors” — the opposite. Gradle is right; the IDE’s index is stale. Sync, or invalidate caches.</li></ul><p>That last pair gives you a genuinely useful instinct: the compiler is the source of truth; the IDE is a cache.</p><h3>Part 8 — From assembleRelease to a file on a phone</h3><p>Now we can fill in the ??? box from Part 0 with real task names.</p><pre>.kt files ──► compileReleaseKotlin ──► .class files<br>                       ▲<br>  res/ ──► mergeReleaseResources ──► AAPT2 ──► compiled res + R class<br>                       │<br>  AndroidManifest.xml (yours + every library&#39;s)<br>        └──► processReleaseManifest ──► one merged manifest<br>                       │<br>  .class files ──► R8 ──► shrunk + obfuscated .class<br>                       │<br>                     D8 ──► classes.dex  (Android bytecode)<br>                       │<br>              packageRelease ──► unsigned .apk (a ZIP)<br>                       │<br>              signing with your keystore ──► signed .apk<br>                       │<br>                   zipalign ──► aligned .apk ──► installable</pre><p>Four things in there are worth knowing properly.</p><h3>Manifest merger</h3><p>Your manifest is merged with every library’s manifest. A library can add permissions you never asked for. Check the merged output at build/intermediates/merged_manifests/.</p><p>I’ve seen an analytics SDK quietly add READ_PHONE_STATE, which triggered a Play Store policy review and delayed a release by a week. You can strip one:</p><pre>&lt;uses-permission android:name=&quot;android.permission.READ_PHONE_STATE&quot;<br>    tools:node=&quot;remove&quot; /&gt;</pre><p>Make reading your merged release manifest part of your release checklist. It takes two minutes.</p><h3>R8 — shrinking and obfuscation</h3><p>R8 deletes code nothing references and renames what survives to a.b.c. Smaller APK, harder to reverse-engineer.</p><p>R8 reasons statically. Reflection is invisible to it. So Gson/Moshi model classes, anything named in XML, anything loaded by name, can be deleted or renamed — and your app crashes only in release.</p><p>That’s what proguard-rules.pro is for:</p><pre>-keep class com.example.model.** { *; }<br>-keepattributes Signature, *Annotation*</pre><blockquote><em>The mistake that costs this industry the most: shipping a release build that was never </em>tested<em> as a release build. </em><em>isMinifyEnabled = false in debug means debug can never reveal an R8 bug. Every team that has skipped release-build QA has eventually shipped a crash-on-launch. Build and smoke-test the actual release variant before every ship. Non-negotiable.</em></blockquote><p>Also: build/outputs/mapping/release/ contains mapping.txt (deobfuscates crash traces — upload it to your crash reporter or your production stack traces are gibberish), usage.txt (what was removed), and seeds.txt (what was kept).</p><h3>Signing</h3><p>Android refuses to install unsigned APKs. Debug builds use an auto-generated debug key. Release builds use <em>your</em> key.</p><pre>signingConfigs {<br>    create(&quot;release&quot;) {<br>        storeFile     = file(System.getenv(&quot;KEYSTORE_PATH&quot;) ?: &quot;dummy.jks&quot;)<br>        storePassword = System.getenv(&quot;KEYSTORE_PASSWORD&quot;)<br>        keyAlias      = System.getenv(&quot;KEY_ALIAS&quot;)<br>        keyPassword   = System.getenv(&quot;KEY_PASSWORD&quot;)<br>    }<br>}</pre><p>Environment variables. Never literals in the build file. Never the keystore in git.</p><p>If you lose your release key and you’re not on Play App Signing, you can never update your app again. You’d have to publish a brand-new listing and lose every install, rating and review you ever earned. Back it up in a company vault, in two places.</p><h3>APK vs AAB</h3><p>assembleRelease produces an .apk. bundleRelease produces an .aab (Android App Bundle), which is what Play wants. Play then generates per-device APKs from it — only the right screen density, the right CPU architecture, the right language — typically 20–40% smaller downloads.</p><h3>Part 9 — Multi-module, and the build-time physics of it</h3><p>Single module:</p><pre>change 1 line  ──►  recompile EVERYTHING  ──►  5 minutes</pre><p>Multi module:</p><pre>:app ──► :feature-login ──► :core-network ──► :core-model<br>change a line in :feature-login<br>       └──► recompile :feature-login and :app only.<br>            :core-network and :core-model: UP-TO-DATE.</pre><p>Plus, independent modules build in parallel.</p><h3>The two failure modes</h3><p>1. The flat graph. Fifty modules that all depend on one :common module that everything imports. Change :common and all fifty rebuild. You paid the full complexity cost of modularisation and got none of the speed. Fix: split god-modules, keep leaves leafy.</p><p>2. api leakage. Covered above. api effectively flattens your graph even when the diagram still looks layered.</p><h3>What a serious team does about it</h3><p>They enforce the layering in the build, as shown in section 3.2. They name modules by layer. And on CI, instead of testing all four hundred modules on every merge request, they compute which modules are reachable from the changed files and test only those. There’s a well-known open-source plugin for this — Dropbox’s affected-module-detector. It can turn a ninety-minute pipeline into a ten-minute one.</p><p>That’s what “build engineering” means as a discipline: treating build time as a product metric with a salary attached to it.</p><h3>Part 10 — Writing your own task (demystifying the magic)</h3><p>A task is just a class with an action. Five lines:</p><pre>tasks.register(&quot;printVersion&quot;) {<br>    doLast {<br>        println(&quot;versionName = ${android.defaultConfig.versionName}&quot;)<br>    }<br>}</pre><p>./gradlew printVersion prints it.</p><p>Notice doLast { }. Code <em>inside</em> it runs during the execution phase. Code outside runs during configuration — on every build, for every command. Getting that wrong is the most common way people slow down a build without ever realising it.</p><p>A proper, cacheable task declares its inputs and outputs:</p><pre>abstract class GenerateBuildInfoTask : DefaultTask() {<br>    @get:Input      abstract val versionName: Property&lt;String&gt;<br>    @get:OutputFile abstract val outputFile: RegularFileProperty<br>    @TaskAction<br>    fun generate() {<br>        outputFile.get().asFile.writeText(&quot;version=${versionName.get()}&quot;)<br>    }<br>}</pre><p>Because inputs and outputs are declared, Gradle can skip it when up-to-date and cache it when it isn’t.</p><p>Undeclared inputs give you wrong results. Undeclared outputs mean it is never cached. That’s the entire contract.</p><h3>Part 11 — Errors you will meet, and how to read them</h3><p>Could not resolve com.foo:bar:1.2.3 Gradle asked every repository and nobody had it. Typo in the coordinates, missing repository, private repo without credentials, or you&#39;re offline. Check repositories { } first.</p><p>Duplicate class kotlin.collections.X found in modules ... Two libraries ship the same class. Usually one of them bundled a dependency instead of declaring it. Find it with dependencyInsight, then exclude the duplicate.</p><p>Manifest merger failed : Attribute application@name value=(...) Two manifests disagree. The error names the exact attribute. Fix with tools:replace=&quot;android:name&quot;.</p><p>Cannot fit requested classes in a single dex file (# methods: 72000 &gt; 65536) The 64K method limit. Set multiDexEnabled = true (free if minSdk &gt;= 21), then ask <em>why</em> you have 72,000 methods. It&#39;s usually one bloated dependency.</p><p>Unsupported class file major version 65 Your JDK is newer than the toolchain expects. 61 means Java 17, 65 means Java 21. Align your JDK with what your AGP version supports.</p><p>Inconsistent JVM-target compatibility compileOptions and kotlinOptions disagree. See section 3.4.</p><p>OutOfMemoryError: Java heap space during the build Raise org.gradle.jvmargs — or kotlin.daemon.jvmargs if the stack trace mentions the Kotlin compiler.</p><p>Works in debug, crashes in release R8 removed or renamed something reflective. That’s the answer about 95% of the time. Add keep rules and check usage.txt.</p><p>The general technique: read the <em>first</em> error, not the last. --stacktrace for a Gradle-internal failure, --info to see why a task ran, --scan when you&#39;d rather hand a colleague a link than nine hundred lines of log.</p><h3>Part 12 — Mistakes I’ve watched cost real money</h3><p>These are the ones that leave marks.</p><p>Committing a config file with production keys to a public repo. Rotate everything, immediately. Treat every secret that has ever touched git as burned.</p><p>A debugImplementation tool declared as implementation. A network inspector shipped to production. Every user could read every API call the app made, auth headers included. Caught in a pentest. Audit your release APK&#39;s dependency list — don&#39;t assume.</p><p>Not pinning the Gradle/AGP version, then “it works on my machine.” Two days of a five-person team’s time, gone. The wrapper exists for exactly this.</p><p>clean in the CI script &quot;to be safe.&quot; It was never unsafe. It just made every CI run four times slower, forever, for everyone. Nobody questioned it for a year. If you need clean for correct builds, fix the task that&#39;s lying about its inputs.</p><p>Bumping targetSdk in release week. Background behaviour changed; a core flow silently failed for a large chunk of users. Day one of the cycle. Never day thirty.</p><p>api instead of implementation in a base module. A difference that looks like one word and added roughly eight minutes to every incremental build across the team. Multiply by forty engineers times ten builds a day and compute the annual cost. Build speed is a product feature.</p><p>No applicationIdSuffix on debug. QA kept overwriting their production app and losing test data. A one-line fix that nobody had made in three years.</p><p>Version numbers copy-pasted across a hundred modules. A security patch for a networking library took a full sprint to roll out, because nobody could confidently find every usage. Version catalogs turn that sprint into a one-line merge request.</p><h3>Part 13 — The practices worth internalising</h3><p>On correctness</p><ul><li>Wrapper always, bare gradle never. Commit the wrapper jar.</li><li>Pin every version explicitly. Never 1.2.+ or latest.release. Non-reproducible builds mean a build that passed yesterday can fail today with zero commits — and that an upstream compromise ships straight to your users.</li><li>Secrets from environment variables or a vault. Never from a build file. Never from git.</li><li>Test the release variant before every ship.</li><li>Upload mapping.txt to your crash reporter on every release build.</li></ul><p>On speed</p><ul><li>implementation by default; api only when genuinely required.</li><li>Enable parallel, caching, and configuration cache. Add a remote build cache if you have CI.</li><li>Keep the configuration phase free of I/O and subprocesses.</li><li>Turn on only the buildFeatures a module actually needs.</li><li>Prefer KSP over kapt.</li><li>Measure before you optimise. --scan is free and shows you exactly where the time went.</li></ul><p>On structure</p><ul><li>Convention plugins in buildSrc or build-logic. Never copy-paste build config.</li><li>Version catalogs for every version.</li><li>Enforce module rules in settings.gradle.kts, not in a wiki.</li><li>Build files should be short and declarative. If your build.gradle.kts needs a code review to understand, the logic belongs in a plugin.</li></ul><h3>One sentence to remember all of it</h3><blockquote><em>Gradle is a generic task engine that AGP teaches to speak Android. </em><em>settings.gradle.kts says who&#39;s in the build. Each module&#39;s </em><em>build.gradle.kts says how that module is built. Sync runs the first two phases for the IDE&#39;s benefit. And everything about build speed reduces to one question — did this task&#39;s declared inputs change?</em></blockquote><h3>Practice — actually do these</h3><p>Reading this article gets you maybe 30% of the way. These exercises get you the rest.</p><p>1. Read your own dependency tree (15 min)</p><pre>./gradlew :app:dependencies --configuration debugRuntimeClasspath</pre><p>Pick a transitive library you don’t recognise and find out who pulled it in:</p><pre>./gradlew :app:dependencyInsight --dependency okhttp --configuration debugRuntimeClasspath</pre><p>Write the answer in one sentence: <em>“okhttp is here because X depends on Y depends on okhttp, and version Z won because ___.”</em></p><p>2. Prove the up-to-date mechanism to yourself (10 min)</p><p>Run ./gradlew :app:assembleDebug twice. Then run it a third time with --info and grep for UP-TO-DATE. Explain out loud why the second run was faster, using the word &quot;inputs.&quot;</p><p>3. Build a toy project from scratch (60 min)</p><p>New empty Android project. Then, by hand:</p><ul><li>add a second module :core and wire it into settings.gradle.kts</li><li>move one data class into :core, depend on it with implementation(project(&quot;:core&quot;))</li><li>add a flavor dimension with free and paid</li><li>give each flavor a different buildConfigField(&quot;String&quot;, &quot;TIER&quot;, ...)</li><li>add applicationIdSuffix = &quot;.debug&quot; and install debug and release on one device at the same time</li><li>list the variants with ./gradlew tasks | grep assemble — and predict the list <em>before</em> you run it</li></ul><p>4. The api experiment (30 min)</p><p>In that toy project, have :core expose Retrofit via implementation. Try to use a Retrofit type in :app. It fails. Change it to api. It compiles. Now write two sentences explaining what changed and what it cost you.</p><p>5. Break R8 deliberately (45 min)</p><p>Add a Gson data class, set isMinifyEnabled = true, build release, install, and watch it fail to parse. Fix it with a -keep rule. Then find the class in build/outputs/mapping/release/usage.txt and confirm it was being stripped.</p><p>6. Write a convention plugin (60 min)</p><p>Create buildSrc/src/main/kotlin/myapp.android.library.gradle.kts, move the shared android { } block into it, and reduce :core&#39;s build file to three lines.</p><p>7. Teach it back</p><p>Explain to someone, without notes, the difference between compileSdk, minSdk and targetSdk, and what Gradle Sync does. Under three minutes, no hesitation. That&#39;s the bar.</p><p>If this was useful, the highest-value thing you can do next is exercise on your actual production project, today. Almost everyone finds something surprising in their dependency tree.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4392d04d1e3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Kotlin’s inline and reified Keywords Exist (And How They Solve Java’s Oldest Flaw)]]></title>
            <link>https://proandroiddev.com/why-kotlins-inline-and-reified-keywords-exist-and-how-they-solve-java-s-oldest-flaw-f390508339cd?source=rss-718ce0ca0016------2</link>
            <guid isPermaLink="false">https://medium.com/p/f390508339cd</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Sehaj kahlon]]></dc:creator>
            <pubDate>Fri, 25 Sep 2026 10:02:45 GMT</pubDate>
            <atom:updated>2026-09-27T16:58:42.778Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*23YGD7LtnnOHGaz62Qyd0A.png" /></figure><p>Why some of the most elegant APIs in Kotlin — first&lt;T&gt;(), Gson().fromJson&lt;T&gt;(), Jetpack’s viewModels&lt;T&gt;() — could never have existed without two keywords most developers use daily but rarely stop to understand.</p><pre>inline fun  makeInstance(): T =<br>    T::class.java.getDeclaredConstructor().newInstance()</pre><p>Generics on the JVM have a strict rule: you cannot use a type parameter T at runtime. Calling T::class, instantiating new T(), or checking if (x is T) is normally forbidden. The compiler will complain that the type information is missing.</p><p>Yet, this function compiles and works flawlessly.</p><p>The secret lies in two keywords: inline and reified. Understanding how they interact changes how you read idiomatic Kotlin, from JSON parsers to network clients.</p><h3>The Problem: The JVM’s Amnesia</h3><p>When you write generic code, you use T as a placeholder for a future type:</p><pre>class Box(val value: T)<br><br>val intBox = Box(5)          // T is Int<br>val stringBox = Box(&quot;hello&quot;) // T is String</pre><p>At compile time, Kotlin knows exactly what T is. It uses this knowledge to catch mistakes, immediately stopping you if you try to put a String into intBox.</p><p>But when compiled to run on the JVM, this knowledge vanishes. This design decision is called <strong>type erasure</strong>.</p><p>Introduced for backward compatibility in 2004, Java’s generics are largely a compile-time illusion. At runtime, the JVM simply sees “a Box holding an Object.&quot; The concrete type is erased.</p><p>Because of this, you cannot use a generic type parameter as a real class at runtime. In standard Java, the workaround is tedious: you must manually pass a Class token everywhere just to keep the type around.</p><p>Kotlin found a way to bypass this entirely.</p><h3>The First Half of the Trick: inline</h3><p>To understand the solution, we first need to look at inline—a keyword that originally has nothing to do with generics.</p><p>Normally, a function call is a detour. The program jumps to the function’s location in memory, executes it, and jumps back. Every caller shares one compiled copy of the function.</p><p>Marking a function inline changes this. Instead of jumping to the function, the compiler <strong>physically pastes the function&#39;s code directly into the caller</strong>.</p><pre>inline fun measureAndLog(label: String, block: () -&gt; Unit) {<br>    val start = System.currentTimeMillis()<br>    block()<br>    println(&quot;\(label took\){System.currentTimeMillis() - start}ms&quot;)<br>}</pre><p>When you call measureAndLog, the function boundary disappears. The compiler takes the logic and drops it exactly where you made the call.</p><p>While primarily used to speed up functions that take lambdas, this copy-paste mechanic creates a fascinating loophole for generics.</p><h3>The Second Half: reified</h3><p>Because an inlined function’s body is physically copied into the caller, the compiler already knows the concrete types being used at that exact location.</p><p>There is no longer a function boundary for the generic type to be erased across. The code is sitting right there alongside the real types.</p><p>Kotlin lets you exploit this with the reified keyword</p><pre>inline fun  makeInstance(): T =<br>    T::class.java.getDeclaredConstructor().newInstance()</pre><p>The reified keyword tells the compiler: <em>do not erase this type. Keep it real.</em></p><p>When you call makeInstance(), the compiler pastes the code and replaces every mention of T with User. It acts exactly as if you had hardcoded User::class.java yourself.</p><p>This brings us to the golden rule of Kotlin generics: <strong>reified only works on </strong><strong>inline functions.</strong> Standard functions are compiled once as a shared unit, meaning they still suffer from type erasure.</p><h3>The Hidden Cost in Tooling</h3><p>This brilliant workaround has one minor catch regarding code metrics.</p><p>Because inlined functions are duplicated rather than invoked like standard methods, code coverage tools (like JaCoCo) often fail to track them correctly.</p><p>Your tests might cover the logic flawlessly, but the coverage report will show 0% for the original generic function. It is a harmless compiler artifact, but knowing about it will save you hours of debugging your test suite.</p><p>Type erasure is a permanent JVM limitation. But by physically relocating code with inline and preserving types with reified, Kotlin turns a rigid platform constraint into an invisible implementation detail.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f390508339cd" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/why-kotlins-inline-and-reified-keywords-exist-and-how-they-solve-java-s-oldest-flaw-f390508339cd">Why Kotlin’s inline and reified Keywords Exist (And How They Solve Java’s Oldest Flaw)</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kotlin Flows in Android: A Clear Mental Model]]></title>
            <link>https://medium.com/@sehajkahlon437/kotlin-flows-in-android-a-clear-mental-model-4f91919b122f?source=rss-718ce0ca0016------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f91919b122f</guid>
            <category><![CDATA[kotlin-stateflow]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Sehaj kahlon]]></dc:creator>
            <pubDate>Sun, 06 Sep 2026 11:47:54 GMT</pubDate>
            <atom:updated>2026-09-06T11:47:54.704Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UD56ZLAqsqKDn09s3qqffA.png" /></figure><blockquote><strong><em>The Big Picture</em></strong><em> If you are building Android apps, you have likely encountered terms like </em><em>Flow, </em><em>StateFlow, and </em><em>SharedFlow. Whether you are new to the architecture or just looking to solidify your understanding, the official documentation can sometimes feel overwhelming.</em></blockquote><blockquote><em>Let’s step back and build a simple, reliable mental model from scratch. No complex jargon — just plain English.</em></blockquote><h3>Why Do We Need Flow in the First Place?</h3><p>Imagine your app displays a user’s download progress: 0% → 20% → 40% → 80% → 100%.</p><p>A standard Kotlin function returns only once. After returning 20, the function is finished. It cannot magically wake up later to return 40, and then 80.</p><p>But Android data changes constantly over time:</p><ul><li>Download progress updates.</li><li>A user types in a search box.</li><li>Network requests go from “loading” to “success”.</li></ul><p>We need a way to deliver <strong>multiple values over time</strong>. That is exactly what Flow does.</p><h3>1. Flow Is a Pipe</h3><p>Think of Flow as a water pipe connecting two ends: a <strong>Producer</strong> and a <strong>Collector</strong>.</p><ul><li><strong>Producer:</strong> Creates the values and puts them into the pipe (emit).</li><li><strong>Flow:</strong> The pipe itself.</li><li><strong>Collector:</strong> Receives the values coming out of the pipe (collect).</li></ul><p>Here is what that looks like in code:</p><pre>fun getNumbers(): Flow&lt;Int&gt; = flow {<br>    emit(1)<br>    delay(1000)<br>    emit(2)<br>    delay(1000)<br>    emit(3)<br>}</pre><p>Read it like a script: <em>Send 1, wait one second, send 2, wait one second, send 3.</em></p><p>To actually receive those numbers, we must collect them:</p><pre>getNumbers().collect { number -&gt;<br>    println(number)<br>}</pre><blockquote><strong>The Golden Rule:</strong> A flow emits values; a collector receives them. Because collecting can take a long time (like waiting for network updates), collect must run inside a Coroutine.</blockquote><h3>2. A Regular Flow is “Cold”</h3><p>If you create a standard flow but never collect it, nothing happens. The code inside the flow builder doesn’t start running until someone is there to listen.</p><p>This is called a <strong>cold flow</strong>.</p><p>Think of it like a YouTube video:</p><ul><li>The video doesn’t play until you press Play.</li><li>Every viewer can start it from the beginning.</li><li>If two different Coroutines collect the same Flow, they each get their own separate run of the data.</li></ul><h3>3. UI State and StateFlow</h3><p>In Android, your screen has a “State”. For example:</p><ul><li>isLoading = false</li><li>userName = &quot;&quot;</li><li>errorMessage = null</li></ul><p>This information describes <strong>what is true right now</strong>. If the user profile finishes loading, the state changes, and the UI needs the latest state to redraw the screen. This is the job of StateFlow.</p><p>Think of StateFlow as a <strong>whiteboard</strong>.</p><p>If the whiteboard currently says “Loading”, anyone who walks into the room (or opens the screen) sees “Loading”. When the data is ready, the ViewModel erases the old content and writes “User loaded”.</p><p>To create our whiteboard, we need an initial value (a whiteboard can’t be null; it has to show <em>something</em>, even if it’s blank data):</p><pre>private val _uiState = MutableStateFlow(UserUiState())</pre><p>When we need to update it, we modify the value:</p><pre>_uiState.update { oldState -&gt;<br>    oldState.copy(isLoading = true)<br>}</pre><h3>4. The “Two Variable” Rule</h3><p>You will almost always see StateFlow set up like this in a ViewModel:</p><pre>private val _uiState = MutableStateFlow(UserUiState())<br>val uiState: StateFlow&lt;UserUiState&gt; = _uiState.asStateFlow()</pre><p>This looks repetitive, but it is for security:</p><ul><li><strong>Inside the ViewModel:</strong> We use _uiState (Mutable) so we can change the data.</li><li><strong>Outside the ViewModel:</strong> The UI observes uiState (Read-only) so it can only react to changes.</li></ul><p>If we didn’t do this, the UI could accidentally overwrite the state directly, which breaks the architecture.</p><blockquote><strong><em>Memory Rule:</em></strong><em> Mutable inside, read-only outside.</em></blockquote><h3>5. What About SharedFlow?</h3><p>Not everything on a screen represents the <em>current state</em>. Sometimes, things are one-off <strong>events</strong>.</p><p>For example, when a user saves their profile, you might want to show a Snackbar saying &quot;Profile saved&quot;.</p><ul><li><strong>State:</strong> “The user’s name is Name.” (Describes the present).</li><li><strong>Event:</strong> “The profile was saved.” (Describes a moment in time).</li></ul><p>If you put that Snackbar message in a StateFlow, the whiteboard remembers it. If the user rotates their phone, the screen recreates itself, reads the whiteboard, and shows the Snackbar a second time!</p><p>SharedFlow is built for broadcasting events. It does not need an initial value, and it doesn&#39;t force new collectors to see the old messages.</p><pre>private val _events = MutableSharedFlow&lt;UiEvent&gt;()<br>val events: SharedFlow&lt;UiEvent&gt; = _events.asSharedFlow()</pre><h3>6. StateFlow vs. SharedFlow: How to Choose</h3><p>When building a feature, ask yourself: <strong>“If the screen disappears and returns, should it immediately receive this value again?”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G3j4OFogsuzGWRMWxIh43A.png" /></figure><h3>7. Flow Operators in Plain English</h3><p>Operators modify values traveling through the pipe before they reach the collector. Here are the most common ones you will use:</p><ul><li><strong>map</strong>: Changes each value. <em>(Input: 1, 2, 3 → Output: 2, 4, 6)</em></li><li><strong>filter</strong>: Keeps only values that match a condition. <em>(Input: 2, 7, 4, 9 → filter &gt; 5 → Output: 7, 9)</em></li><li><strong>debounce</strong>: Waits for an action to pause. Perfect for search bars. If a user types &quot;a → ab→ abc&quot;, debounce(300) waits until they stop typing for 300 milliseconds before sending the final word.</li><li><strong>distinctUntilChanged</strong>: Ignores repeated identical values in a row. <em>(Input: cat, cat, dog → Output: cat, dog)</em></li><li><strong>flatMapLatest</strong>: Cancels the old operation if a new one starts. If you are fetching search results for &quot;seh&quot; and the user types &quot;sehaj&quot;, it cancels the first network request and only cares about the newest one.</li></ul><h3>8. Collecting Safely in the UI</h3><p>When a user backgrounds your app, the UI should stop collecting data to save battery and resources.</p><p>In Jetpack Compose, doing this is exactly one line of code:</p><pre>val state by viewModel.uiState.collectAsStateWithLifecycle()</pre><p>This simply means: <em>Collect this flow while the screen is active, and pause it when the screen is hidden.</em></p><h3>The Final Cheat Sheet</h3><p>Before you write your next feature, run it through this checklist:</p><ul><li>Search text → <strong>StateFlow</strong></li><li>Search results → <strong>StateFlow</strong></li><li>Loading indicator → <strong>StateFlow</strong></li><li>Error screen → <strong>StateFlow</strong></li><li>“Link Copied!” toast → <strong>SharedFlow</strong></li></ul><p>Mastering Kotlin Flows isn’t about memorizing every function in the documentation. It is about understanding the difference between a state that persists and an event that passes by. Once you have that mental model, the rest falls into place.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f91919b122f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying Retrofit and OkHttp: An Android Developer’s Guide to Networking]]></title>
            <link>https://medium.com/@sehajkahlon437/demystifying-retrofit-and-okhttp-an-android-developers-guide-to-networking-059fa036bb41?source=rss-718ce0ca0016------2</link>
            <guid isPermaLink="false">https://medium.com/p/059fa036bb41</guid>
            <category><![CDATA[retrofit]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[okhttp]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Sehaj kahlon]]></dc:creator>
            <pubDate>Sat, 05 Sep 2026 17:30:07 GMT</pubDate>
            <atom:updated>2026-09-13T05:45:05.868Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*owqdpQxCBX0Geq1FsQVkJw.png" /></figure><p>If you’ve built an Android app in the last few years, you’ve probably used Retrofit. It’s the undisputed king of Android networking. But how often do we just copy-paste the setup code, add a few annotations, and hope for the best?</p><p>Today, we are going to learn Retrofit and OkHttp from first principles. We won’t just memorize annotations; we will understand exactly how these tools work together to get data from a server onto your user’s screen.</p><h3>The Actual Problem</h3><p>Imagine your app needs to display a user profile. The server holds this JSON data:</p><pre>{<br>  &quot;id&quot;: 42,<br>  &quot;name&quot;: &quot;name&quot;,<br>  &quot;email&quot;: &quot;name@example.com&quot;<br>}</pre><p>To get this data, your app needs to create an HTTP request, send it across the internet, receive the JSON, detect if it succeeded or failed, convert that JSON into Kotlin objects, and finally hand it over to the UI. Oh, and it needs to handle timeouts, authentication, and coroutine cancellation along the way.</p><p>That is a lot of heavy lifting. This is exactly where the Retrofit and OkHttp tag team comes in.</p><h3>Retrofit vs. OkHttp: The Restaurant Analogy</h3><p>Think of your networking layer like a restaurant:</p><ul><li><strong>You (Your Kotlin function):</strong> The customer placing an order.</li><li><strong>Retrofit:</strong> The waiter. You tell Retrofit what you want using simple Kotlin functions, and it translates your order into standard HTTP language. It is a <strong>type-safe API layer</strong>.</li><li><strong>OkHttp:</strong> The delivery driver. It takes the HTTP request from Retrofit, navigates the internet, handles the actual connection, deals with traffic (timeouts/retries), and brings the package (the response) back. It is the actual <strong>HTTP client</strong>.</li><li><strong>The Converter (e.g., Moshi):</strong> The kitchen staff that unpacks the raw JSON ingredients and plates them beautifully into Kotlin Data Classes.</li></ul><blockquote><strong><em>The Golden Rule:</em></strong><em> Retrofit describes the API. OkHttp does the actual network work. The Converter translates the JSON.</em></blockquote><h3>Step 1: Model the Server Contract</h3><p>Before we write any networking code, we need to define what the data looks like. This is where we create a Data Transfer Object (DTO).</p><pre>@JsonClass(generateAdapter = true)<br>data class UserDto(<br>    val id: Long,<br>    val name: String,<br>    val email: String?<br>)</pre><p>Notice that email is nullable. Why? Because the network is unpredictable. The server might omit it, and your app shouldn&#39;t crash if it does.</p><p>However, <strong>do not let DTOs leak into your UI</strong>. Keep them at the network boundary and map them to a clean Domain Model for the rest of your app to use:</p><pre>data class User(<br>    val id: Long,<br>    val displayName: String,<br>    val email: String<br>)<br><br>fun UserDto.toDomain(): User =<br>    User(<br>        id = id,<br>        displayName = name.trim(),<br>        email = email.orEmpty() // Provide a sensible default<br>    )</pre><h3>Step 2: Define the Retrofit API</h3><p>Now we need to tell Retrofit what our endpoint looks like.</p><pre>interface UserApi {<br>    @GET(&quot;users/{id}&quot;)<br>    suspend fun getUser(<br>        @Path(&quot;id&quot;) id: Long<br>    ): UserDto<br>}</pre><p>Read this in plain English: <em>When </em><em>getUser(42) is called, send a </em><em>GET request to </em><em>/users/42, wait without blocking the main thread (thanks to </em><em>suspend), and decode the successful JSON into a </em><em>UserDto.</em></p><h3>Step 3: Wire Up the Engine</h3><p>We have our blueprint. Now let’s build the engine. We need to construct our OkHttp client and pass it to Retrofit.</p><pre>// 1. Set up OkHttp (The Delivery Driver)<br>val logging = HttpLoggingInterceptor().apply {<br>    level = HttpLoggingInterceptor.Level.BASIC<br>}<br><br>val okHttpClient = OkHttpClient.Builder()<br>    .connectTimeout(15, TimeUnit.SECONDS)<br>    .readTimeout(30, TimeUnit.SECONDS)<br>    .addInterceptor(logging)<br>    .build()<br><br>// 2. Set up Moshi (The Kitchen Staff)<br>val moshi = Moshi.Builder()<br>    .add(KotlinJsonAdapterFactory())<br>    .build()<br><br>// 3. Set up Retrofit (The Waiter)<br>val retrofit = Retrofit.Builder()<br>    .baseUrl(&quot;https://api.example.com/&quot;)<br>    .client(okHttpClient)<br>    .addConverterFactory(MoshiConverterFactory.create(moshi))<br>    .build()<br><br>val userApi = retrofit.create(UserApi::class.java)</pre><p><em>(Note: Always remember the trailing slash </em><em>/ on your base URL!)</em></p><h3>Step 4: Intercepting the Request</h3><p>What if every request needs an authentication token? Instead of manually adding it to every API call, OkHttp lets us use an <strong>Interceptor</strong>. An interceptor can pause the request, modify it, and then send it on its way.</p><pre>class AuthInterceptor(<br>    private val tokenProvider: TokenProvider<br>) : Interceptor {<br><br>    override fun intercept(chain: Interceptor.Chain): Response {<br>        val original = chain.request()<br>        val token = tokenProvider.currentToken()<br><br>        val authenticatedRequest = original.newBuilder()<br>            .apply {<br>                if (token != null) {<br>                    header(&quot;Authorization&quot;, &quot;Bearer $token&quot;)<br>                }<br>            }<br>            .build()<br><br>        return chain.proceed(authenticatedRequest)<br>    }<br>}</pre><h3>Step 5: Handling the Chaos (Error Management)</h3><p>Here is a massive distinction that trips up many junior developers: <strong>An HTTP </strong><strong>404 Not Found is a successful network connection.</strong> It means OkHttp successfully reached the server, and the server successfully replied &quot;I don&#39;t have that.&quot;</p><p>A true network failure (like no Wi-Fi) throws an Exception.</p><p>To handle this cleanly in a production app, wrap your responses in a sealed interface:</p><pre>sealed interface NetworkResult&lt;out T&gt; {<br>    data class Success&lt;T&gt;(val data: T) : NetworkResult&lt;T&gt;<br>    data class HttpError(val code: Int) : NetworkResult&lt;Nothing&gt;<br>    data object NoConnection : NetworkResult&lt;Nothing&gt;<br>    data object Timeout : NetworkResult&lt;Nothing&gt;<br>    data class Unknown(val cause: Throwable) : NetworkResult&lt;Nothing&gt;<br>}</pre><p>Now, your Repository can catch the exact issue and safely pass it to your ViewModel:</p><pre>class UserRepository(private val api: UserApi) {<br>    <br>    suspend fun getUser(id: Long): NetworkResult&lt;User&gt; =<br>        try {<br>            // Success! Map DTO to Domain.<br>            NetworkResult.Success(api.getUser(id).toDomain())<br>        } catch (error: HttpException) {<br>            // Reached server, but got a 4xx or 5xx code<br>            NetworkResult.HttpError(error.code())<br>        } catch (error: SocketTimeoutException) {<br>            // Took too long<br>            NetworkResult.Timeout<br>        } catch (error: IOException) {<br>            // No internet connection<br>            NetworkResult.NoConnection<br>        } catch (error: CancellationException) {<br>            // The coroutine was cancelled (e.g., user navigated away)<br>            // NEVER swallow this exception!<br>            throw error<br>        } catch (error: Throwable) {<br>            NetworkResult.Unknown(error)<br>        }<br>}</pre><h3>5 Golden Rules of Android Networking</h3><p>If you take nothing else away from this article, remember these rules:</p><ul><li><strong>Never swallow </strong><strong>CancellationException:</strong> Coroutines rely on this to clean up resources. If you catch generic Throwables, always re-throw CancellationException.</li><li><strong>Don’t leak DTOs:</strong> Map your network models to domain models right at the repository layer.</li><li><strong>T vs </strong><strong>Response&lt;T&gt;:</strong> If your API interface returns UserDto, Retrofit throws an error for non-200 responses. If it returns Response&lt;UserDto&gt;, it gives you the raw HTTP metadata to inspect manually. Stick to T unless you specifically need to read raw HTTP headers.</li><li><strong>Main-safety is built-in:</strong> Retrofit suspend functions are already asynchronous. You don&#39;t need to wrap every API call in withContext(Dispatchers.IO).</li><li><strong>Reuse your clients:</strong> OkHttp and Retrofit maintain expensive shared resources like connection pools. Use Dependency Injection (like Hilt or Dagger) to provide them as Singletons.</li></ul><h3>The Takeaway</h3><p>Retrofit and OkHttp are not magic. Retrofit takes your Kotlin code and writes an HTTP request. OkHttp puts that request in a truck, drives it across the internet, and brings back the result. By understanding this boundary, modeling your data carefully, and handling errors gracefully, you can build networking layers that are robust, testable, and ready for production.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=059fa036bb41" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Hilt and Dependency Injection in Android: A Pragmatic Guide]]></title>
            <link>https://medium.com/@sehajkahlon437/mastering-hilt-and-dependency-injection-in-android-a-pragmatic-guide-94094ab6525c?source=rss-718ce0ca0016------2</link>
            <guid isPermaLink="false">https://medium.com/p/94094ab6525c</guid>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Sehaj kahlon]]></dc:creator>
            <pubDate>Mon, 31 Aug 2026 14:27:08 GMT</pubDate>
            <atom:updated>2026-08-31T14:27:08.107Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EzRAkZsSQEBlHAsEWj1C8g.png" /></figure><p>If you’ve ever tangled with tightly coupled Android components or struggled to write unit tests because your ViewModel was doing too much heavy lifting, you already know why Dependency Injection (DI) is crucial.</p><p>In modern Android development, <strong>Hilt</strong> is the standard for DI. Built on top of Dagger, it automates the tedious wiring of dependencies and validates your graph at compile time. Whether you are refactoring a legacy codebase or preparing for an SDE 2 interview, understanding how Hilt actually works under the hood is non-negotiable.</p><p>Let’s break down the core concepts, the “Big Three” annotations, and the common traps you need to avoid.</p><h3>1. The Problem Dependency Injection Solves</h3><p>Without DI, a class is responsible for constructing its own dependencies.</p><pre>class UserViewModel : ViewModel() {<br>    private val api = Retrofit.Builder()<br>        .baseUrl(BASE_URL)<br>        .build()<br>        .create(UserApi::class.java)<br><br>    private val repository = DefaultUserRepository(api)<br>}</pre><p>The issues here are glaring:</p><ul><li><strong>Coupling:</strong> The ViewModel knows the infrastructure details of how to build a network client.</li><li><strong>Testing:</strong> You cannot easily substitute a fake repository to test the ViewModel in isolation.</li><li><strong>Duplication:</strong> Object creation and configuration are duplicated across the app.</li><li><strong>Rigidity:</strong> Changing an implementation (like swapping out Retrofit) breaks all its consumers.</li></ul><p><strong>The Solution:</strong> A class should receive what it needs from the outside.</p><pre>class UserViewModel(<br>    private val repository: UserRepository<br>) : ViewModel()</pre><p>Hilt automates this exact process, figuring out how to create the UserRepository and passing it to the ViewModel safely.</p><h3>2. Constructor Injection: Your Default Choice</h3><p>When you own the class and Hilt can directly call its constructor, always default to <strong>Constructor Injection</strong>.</p><pre>class DefaultUserRepository @Inject constructor(<br>    private val api: UserApi<br>) : UserRepository</pre><p><strong>Why is this the gold standard?</strong></p><ul><li>Dependencies are explicitly stated in the constructor.</li><li>Fields can be strictly immutable (val).</li><li>Invalid or partial construction is prevented.</li><li>You can easily pass fakes in plain unit tests without needing Hilt at all.</li></ul><p><em>Note: Avoid field injection (using </em><em>lateinit var) in your own classes unless absolutely necessary. Leave field injection for Android framework components (like Activities or Fragments) that the OS instantiates.</em></p><h3>3. The Big Three: How Hilt Learns to Build Things</h3><p>Hilt needs to know how to construct every dependency in your graph. You teach it using one of three approaches:</p><h4>A. @Inject constructor</h4><p>Use this when <strong>you own the class</strong> and normal constructor invocation is enough.</p><h4>B. @Provides</h4><p>Use this when creation requires custom code, a Builder pattern, or a <strong>third-party library</strong> (where you cannot add @Inject constructor).</p><pre>@Module<br>@InstallIn(SingletonComponent::class)<br>object NetworkModule {<br><br>    @Provides<br>    @Singleton<br>    fun provideRetrofit(): Retrofit =<br>        Retrofit.Builder()<br>            .baseUrl(&quot;https://example.com/&quot;)<br>            .addConverterFactory(GsonConverterFactory.create())<br>            .build()<br>}</pre><h4>C. @Binds</h4><p>Use this for <strong>interface-to-implementation mapping</strong>. It tells Hilt: <em>“When a class asks for this Interface, give it this implementation.”</em> The implementation itself must already be injectable.</p><pre>@Module<br>@InstallIn(SingletonComponent::class)<br>abstract class RepositoryModule {<br><br>    @Binds<br>    @Singleton<br>    abstract fun bindUserRepository(<br>        implementation: DefaultUserRepository<br>    ): UserRepository<br>}</pre><blockquote><strong><em>The Golden Decision Rule:</em></strong></blockquote><blockquote>- Own class + callable constructor -&gt; @Inject constructor</blockquote><blockquote>- Interface -&gt; injectable implementation -&gt; @Binds</blockquote><blockquote>- Builder / factory / 3rd party creation -&gt; @Provides</blockquote><h3>4. Setting up Hilt Entry Points</h3><p>To kick off the dependency graph, your Application class needs an annotation:</p><pre>@HiltAndroidApp<br>class MyApplication : Application()</pre><p>For Android framework components (Activities, Fragments, Views) that need injected fields, use @AndroidEntryPoint:</p><pre>@AndroidEntryPoint<br>class MainActivity : AppCompatActivity() {<br>    @Inject<br>    lateinit var analytics: AnalyticsTracker<br>}</pre><p>Gotcha: If an Activity hosts a Fragment annotated with @AndroidEntryPoint, the Activity must also be annotated with it.</p><h3>5. ViewModels and Compose</h3><p>Hilt integrates beautifully with ViewModelProvider. Never manually construct a Hilt ViewModel in production UI code.</p><pre>@HiltViewModel<br>class UserViewModel @Inject constructor(<br>    private val getUser: GetUserUseCase<br>) : ViewModel()</pre><p>In Jetpack Compose, retrieving this ViewModel is effortless:</p><pre>@Composable<br>fun UserRoute(viewModel: UserViewModel = hiltViewModel()) { ... }</pre><h3>6. Components, Scopes, and the @Singleton Trap</h3><p>A <strong>component</strong> is a dependency container with a defined lifetime (e.g., SingletonComponent lives as long as the app). A <strong>scope</strong> controls instance reuse within that component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lcmr1MkIlOgYAvPqMR6LGw.png" /></figure><h3>7. Context Injection and Memory Leaks</h3><p>Injecting Context is a common source of memory leaks. Hilt provides built-in qualifiers to help you do this safely:</p><pre>class PreferencesManager @Inject constructor(<br>    @ApplicationContext private val context: Context // Safe for Singletons<br>)</pre><p><strong>Warning:</strong> A @Singleton must <em>never</em> retain an @ActivityContext. The singleton outlives the Activity, guaranteeing a memory leak.</p><h3>8. Resolving Ambiguity with Qualifiers</h3><p>What happens if you have two OkHttpClient instances—one for authenticated calls and one for public calls? Hilt won&#39;t know which one to inject. You solve this with @Qualifier.</p><pre>@Qualifier<br>@Retention(AnnotationRetention.BINARY)<br>annotation class AuthenticatedClient<br><br>@Module<br>@InstallIn(SingletonComponent::class)<br>object HttpModule {<br>    @Provides<br>    @Singleton<br>    @AuthenticatedClient<br>    fun provideAuthClient(...): OkHttpClient = ...<br>}</pre><p>Now, just tag the dependency at the injection site:</p><pre>class SecureApiFactory @Inject constructor(<br>    @AuthenticatedClient private val client: OkHttpClient<br>)</pre><h3>9. The One-Minute Memory Map Cheat Sheet</h3><p>Bookmark this section for your next PR or system design interview:</p><ul><li>@Inject constructor -&gt; Hilt can call my constructor.</li><li>@Provides -&gt; Custom, Builder, or 3rd-party creation.</li><li>@Binds -&gt; Maps an interface to its implementation.</li><li>@Qualifier -&gt; Chooses between bindings of the exact same type.</li><li>@Singleton -&gt; Reuses the instance within the application component.</li><li>@HiltViewModel -&gt; Wires up a Hilt-created ViewModel.</li><li>@AndroidEntryPoint -&gt; Injects Android framework components.</li><li>@HiltAndroidApp -&gt; Initializes the app-level Hilt graph.</li></ul><p>Dependency injection doesn’t have to be magic. By leaning into constructor injection and keeping your scopes intentionally restricted, you’ll build an Android app that is robust, modular, and highly testable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94094ab6525c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Engine of Android: Looper, Handler, and MessageQueue]]></title>
            <link>https://proandroiddev.com/the-engine-of-android-looper-handler-and-messagequeue-0142fc194119?source=rss-718ce0ca0016------2</link>
            <guid isPermaLink="false">https://medium.com/p/0142fc194119</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android-internals]]></category>
            <dc:creator><![CDATA[Sehaj kahlon]]></dc:creator>
            <pubDate>Sat, 22 Aug 2026 14:00:56 GMT</pubDate>
            <atom:updated>2026-08-30T16:25:48.435Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nwyUjy6qpUJJ3boYhPMMWw.png" /></figure><p>Every Android app has one <strong>main thread</strong> (the UI thread). This single thread is incredibly busy. It handles drawing all views, processing touch events, running onClick handlers, delivering lifecycle callbacks, and posting LiveData or StateFlow updates.</p><p><strong>How does one single thread handle thousands of events without losing track or crashing?</strong></p><p>The answer lies in a beautiful piece of engineering: the <strong>Looper + MessageQueue + Handler</strong> architecture. It is the engine that powers every Android app, and understanding it will fundamentally change how you write code.</p><p>Let’s dive under the hood.</p><h3>1. The Engine: MessageQueue, Looper, and Handler</h3><p>To process thousands of tasks sequentially, Android uses a classic queuing mechanism broken down into three parts.</p><h4>MessageQueue — The Todo List</h4><p>At its core is the MessageQueue: a queue of Message objects waiting to be processed, sorted by their execution timestamp.</p><pre>MessageQueue:<br>┌──────────────────────────┐<br>│ Draw button (when: 0ms)   │  ← next to process<br>│ Handle click (when: 0ms)  │<br>│ Update text (when: 0ms)   │<br>│ Delayed task (when: 5000) │  ← won&#39;t be picked until 5s later<br>└──────────────────────────┘</pre><p>Every time something needs to happen on the main thread — a draw, a click, or a UI update — it becomes a Message added to this queue. To avoid memory churn and garbage collection pressure, these messages are pooled and recycled using Message.obtain().</p><p>Here is a look at what lives inside a Message:</p><pre>class Message {<br>    int what;           // identifier (like an event type)<br>    int arg1, arg2;     // simple integer args<br>    Object obj;         // arbitrary data<br>    long when;          // timestamp — when should this be processed<br>    Handler target;     // which Handler will process this<br>    Runnable callback;  // or a Runnable to execute<br>}</pre><h4>Looper — The Infinite Loop</h4><p>A Looper sits on a thread and endlessly processes messages from the MessageQueue. Here is a simplified version of the actual Android source code to show you what it does:</p><pre>public static void loop() {<br>    final MessageQueue queue = myLooper().mQueue;<br>    <br>    for (;;) {  // infinite loop<br>        Message msg = queue.next();  // blocks until message available<br>        if (msg == null) return;     // null = quit signal<br>        <br>        msg.target.handleMessage(msg);  // dispatch to the Handler<br>        msg.recycleUnchecked();         // return to pool<br>    }<br>}</pre><p>That’s it. It takes a message, gives it to a Handler to process, recycles it, and repeats forever.</p><blockquote><strong><em>Why do ANRs happen?</em></strong><em> The Looper processes messages </em><strong><em>one at a time, sequentially</em></strong><em>. If your </em><em>onClick handler takes 10 seconds, the Looper is stuck. It can&#39;t process touch events or draw requests. The queue backs up, the screen freezes, and after 5 seconds, the system throws an </em><strong><em>Application Not Responding (ANR)</em></strong><em> dialog.</em></blockquote><p>Wait, if it’s an infinite loop, doesn’t it drain the battery? No. queue.next() doesn&#39;t spin-wait. It uses Linux&#39;s epoll mechanism. If no messages are due, the thread sleeps (zero CPU usage). It only wakes up when a new message arrives or a delayed message&#39;s timer expires.</p><h4>Handler — The Postman</h4><p>The Handler is your interface to this system. It does two things:</p><ol><li><strong>Sends messages</strong> to a Looper’s MessageQueue.</li><li><strong>Processes messages</strong> when the Looper delivers them back.</li></ol><p>Here is how you typically use it:</p><pre>// Post a Runnable — runs on the main thread<br>val mainHandler = Handler(Looper.getMainLooper())<br><br>mainHandler.post {<br>    textView.text = &quot;Updated!&quot; <br>}<br><br>// Post with a delay<br>mainHandler.postDelayed({<br>    showToast(&quot;3 seconds passed&quot;)<br>}, 3000)</pre><p><strong>The Classic Memory Leak Trap</strong> If you’ve been writing Android apps for a while, you’ve probably seen a Handler memory leak. Because inner classes hold implicit references to their outer class, a delayed message can keep an entire Activity in memory long after it’s been destroyed.</p><pre>// ❌ INNER CLASS HANDLER — LEAKS MEMORY<br>class MyActivity : AppCompatActivity() {<br>    val handler = object : Handler(Looper.getMainLooper()) {<br>        override fun handleMessage(msg: Message) {<br>            updateUI() // &#39;this&#39; keeps Activity alive!<br>        }<br>    }<br><br>    fun start() {<br>        handler.sendEmptyMessageDelayed(0, 60_000)  // 1 minute delay<br>    }<br>}</pre><p>The modern, leak-proof way to handle delayed UI work? <strong>Coroutines.</strong></p><pre>// ✅ MODERN FIX: lifecycleScope<br>lifecycleScope.launch {<br>    delay(60_000)<br>    updateUI()  // auto-cancelled when lifecycle destroyed<br>}</pre><h3>2. How Your Daily Tools Map to the Looper</h3><p>You use this system every day without realizing it. All your favorite UI thread utilities are just wrappers around the Handler and MessageQueue.</p><p><strong>runOnUiThread()</strong></p><pre>public void runOnUiThread(Runnable action) {<br>    if (Thread.currentThread() != mUiThread) {<br>        mHandler.post(action);  // posts to main Looper&#39;s queue<br>    } else {<br>        action.run();  // already on main thread, runs directly<br>    }<br>}</pre><p><strong>Dispatchers.Main (Coroutines)</strong> Under the hood, Dispatchers.Main wraps Handler(Looper.getMainLooper()). When you switch context to the main thread, the coroutine continuation is simply posted as a Message to the main thread&#39;s queue.</p><p><strong>LiveData.postValue() vs </strong><strong>setValue()</strong></p><ul><li>setValue() synchronously dispatches updates (must be on the main thread).</li><li>postValue() posts a runnable to the main thread Handler. If you call postValue() multiple times rapidly on a background thread before the Looper gets a chance to process the queue, <strong>only the last value is delivered</strong> (intermediate values are dropped).</li></ul><h3>3. Binder: Breaking Out of the Sandbox (IPC)</h3><p>The Looper manages a single process. But Android apps run in separate, sandboxed memory spaces. Your app needs to talk to the system_server (which runs the ActivityManager, WindowManager, etc.).</p><p>Because processes have separate memory, you can’t just call a function in another process. You need <strong>Binder</strong>, Android’s Inter-Process Communication (IPC) mechanism.</p><pre>┌─────────────────┐                    ┌──────────────────────┐<br>│  Your App       │                    │  system_server       │<br>│  (Process A)    │                    │  (Process B)         │<br>│                 │                    │                      │<br>│  ActivityManager│    Binder Driver   │  ActivityManagerService<br>│  (Proxy/Stub)   │◄──────────────────►│  (Real implementation)<br>│                 │    (Linux kernel)  │                      │<br>└─────────────────┘                    └──────────────────────┘</pre><p>When you call startActivity(intent), here is what actually happens:</p><ol><li>The ActivityManager in your process is just a <strong>Proxy</strong> (a fake object).</li><li>The Proxy serializes your call and Intent into a <strong>Parcel</strong>.</li><li>It sends the Parcel down to the Binder driver in the Linux kernel.</li><li>The kernel routes it to the real ActivityManagerService in system_server.</li><li>The system processes the launch and sends a callback through Binder back to your app.</li></ol><h3>The 1MB Transaction Limit Crash</h3><p>Data sent through Binder is serialized into a Parcel (which is why we implement Parcelable). However, Binder has a shared buffer limit of <strong>~1MB for ALL concurrent transactions</strong> in a process.</p><pre>// ❌ This will crash with TransactionTooLargeException<br>val hugeBitmap = BitmapFactory.decodeResource(resources, R.drawable.huge_image)<br>intent.putExtra(&quot;image&quot;, hugeBitmap)  // Bitmap is too large for Binder<br><br>// ✅ Instead: save to file/cache, pass the identifier<br>val uri = saveBitmapToFile(bitmap)<br>intent.putExtra(&quot;imageUri&quot;, uri.toString())</pre><p>Never stuff massive data into Intents or onSaveInstanceState bundles. Save the data to a repository or ViewModel, and only pass the IDs via Binder.</p><p><em>(Note: If you ever need to create your own cross-process communication, Android provides </em><strong><em>AIDL</em></strong><em> to auto-generate these Proxy and Stub Binder classes for you.)</em></p><h3>4. Choreographer and Frame Timing</h3><p>Finally, how does the Looper know <em>when</em> to draw the UI? Enter the <strong>Choreographer</strong>.</p><p>To maintain 60 frames per second, a frame must be drawn every 16.6ms.</p><pre>Every 16.6ms (60fps), hardware vsync signal fires:<br>    ↓<br>Choreographer posts a high-priority message to main MessageQueue:<br>    ↓<br>Looper picks it up:<br>    ↓<br>1. Process input events (touches)<br>2. Process animations<br>3. Process view layout (measure + layout)<br>4. Process view drawing (draw)<br>    ↓<br>Frame sent to display</pre><p>This is exactly why doing heavy work in onDraw is a cardinal sin:</p><pre>// ❌ Bad — blocking the rendering cycle<br>override fun onDraw(canvas: Canvas) {<br>    val bitmap = BitmapFactory.decodeFile(path) // Takes &gt; 16ms!<br>    canvas.drawBitmap(bitmap, 0f, 0f, null)<br>}</pre><p>If your draw operation takes longer than 16ms, the Choreographer misses the vsync window, dropping the frame and causing visual “jank.”</p><p>When you want to trigger this pipeline manually:</p><ul><li>view.invalidate(): Content changed (like color). Skips layout, goes straight to draw.</li><li>view.requestLayout(): Size/Bounds changed. Triggers the full measure → layout → draw pipeline.</li></ul><h3>The Complete Mental Model</h3><p>If you take away just one thing, let it be this diagram. This is the entire architecture of how your Android app communicates internally and externally:</p><pre>┌────────────────────────────────────────────────────────────────────┐<br>│                         YOUR APP PROCESS                           │<br>│                                                                    │<br>│  ┌──────────── MAIN THREAD ──────────────────────────────────┐     │<br>│  │                                                           │     │<br>│  │   Handler.post()  ───┐                                    │     │<br>│  │   View.post()  ──────┤                                    │     │<br>│  │   runOnUiThread() ───┤     ┌─────────────────┐            │     │<br>│  │   Dispatchers.Main ──┼────►│  MessageQueue   │            │     │<br>│  │   LiveData.post()    │     │  [msg][msg][msg]│            │     │<br>│  │   Choreographer ─────┘     └────────┬────────┘            │     │<br>│  │                                     │                     │     │<br>│  │                                     ▼                     │     │<br>│  │                              ┌─────────────┐              │     │<br>│  │                              │   LOOPER    │              │     │<br>│  │                              │  (forever)  │              │     │<br>│  │                              │  pick msg   │              │     │<br>│  │                              │  process it │              │     │<br>│  │                              └─────────────┘              │     │<br>│  └───────────────────────────────────────────────────────────┘     │<br>│                                                                    │<br>│  ┌──── BACKGROUND THREADS ───┐                                     │<br>│  │  Dispatchers.IO           │                                     │<br>│  │  Dispatchers.Default      │  (post results to main via Handler) │<br>│  └───────────────────────────┘                                     │<br>│                                                                    │<br>│  ┌──── BINDER (IPC) ─────────────────────────────────────────┐     │<br>│  │  ActivityManager (proxy) ──► Binder Driver ──► system_server  │ │<br>│  │  LocationManager (proxy) ──► Binder Driver ──► system_server  │ │<br>│  │  ContentResolver (proxy) ──► Binder Driver ──► other app      │ │<br>│  └───────────────────────────────────────────────────────────┘     │<br>└────────────────────────────────────────────────────────────────────┘</pre><p>Once you understand the Looper, Handler, and Binder, Android stops feeling like magic and starts feeling like a predictable, well-oiled machine.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0142fc194119" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/the-engine-of-android-looper-handler-and-messagequeue-0142fc194119">The Engine of Android: Looper, Handler, and MessageQueue</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design Patterns Explained (With Real Android Examples)]]></title>
            <link>https://medium.com/@sehajkahlon437/design-patterns-explained-with-real-android-examples-40b46cd1e2af?source=rss-718ce0ca0016------2</link>
            <guid isPermaLink="false">https://medium.com/p/40b46cd1e2af</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[software-design-patterns]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Sehaj kahlon]]></dc:creator>
            <pubDate>Sat, 15 Aug 2026 18:23:30 GMT</pubDate>
            <atom:updated>2026-08-15T18:23:30.379Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d_v5GaqXKsfB4MuM1M_ZwA.png" /></figure><h3>I knew zero about design patterns. Then I finally understood them.</h3><p>Every developer has been there. You open a PR review and see: <em>“This should follow the Observer pattern”</em> or <em>“Use a Factory here.”</em> You nod, Google it, read a textbook definition with Shape and Animal examples, and still don&#39;t really <em>get</em> it.</p><p>I was the same. Until I realized something — I was already using design patterns every day. I just didn’t know their names.</p><p>This article explains 8 patterns using code you’ve actually written. No class Dog extends Animal. No UML diagrams. Just real problems and their solutions.</p><h3>What Is a Design Pattern?</h3><p>Imagine you’re building houses. Every architect faces the same problems — “how do I make a door that opens?” or “how do I support a roof?” Over centuries, builders figured out standard solutions. You don’t reinvent a door hinge every time.</p><p>Design patterns are the same thing — but for code. Named, proven solutions to problems that keep showing up.</p><h3>1. Observer — “Hey, Something Changed!”</h3><h4>The Problem</h4><p>You have data that changes (an API response arrives), and multiple parts of your UI need to update. Without a pattern, you’d manually poke every view. Fragile. Easy to miss one.</p><h4>The Solution</h4><p>Let interested parties “subscribe.” When data changes, notify everyone automatically.</p><h4>You Already Use This</h4><pre>// LiveData IS the Observer pattern<br>viewModel.users.observe(viewLifecycleOwner) { users -&gt;<br>    adapter.submitList(users)<br>}<br><br>// StateFlow IS the Observer pattern<br>viewModel.state.collect { state -&gt; renderUI(state) }<br><br>// Click listeners? Observer pattern.<br>button.setOnClickListener { doSomething() }</pre><h4>Under the Hood (Simplified)</h4><pre>class MyLiveData&lt;T&gt; {<br>    private var value: T? = null<br>    private val observers = mutableListOf&lt;(T) -&gt; Unit&gt;()<br><br>    fun observe(observer: (T) -&gt; Unit) {<br>        observers.add(observer)<br>    }<br><br>    fun setValue(newValue: T) {<br>        value = newValue<br>        observers.forEach { it(newValue) }  // notify all subscribers<br>    }<br>}</pre><h4>One-Line Explanation</h4><blockquote><em>The producer of data doesn’t know who’s listening. Listeners don’t know about each other. They’re completely decoupled.</em></blockquote><h3>2. Singleton — “There Can Only Be One”</h3><h4>The Problem</h4><p>Your database, network client, or analytics tracker should exist exactly once. Multiple database instances = data conflicts + wasted memory.</p><pre>// Kotlin makes it trivial<br>object Analytics {<br>    fun trackEvent(name: String) { /* ... */ }<br>}<br>// Same instance everywhere. No second instance possible.</pre><h4>The Solution</h4><p>For things that need initialization:</p><pre>class AppDatabase private constructor(context: Context) {<br>    companion object {<br>        @Volatile private var INSTANCE: AppDatabase? = null<br><br>        fun getInstance(context: Context): AppDatabase {<br>            return INSTANCE ?: synchronized(this) {<br>                INSTANCE ?: buildDatabase(context).also { INSTANCE = it }<br>            }<br>        }<br>    }<br>}</pre><h4>The Catch</h4><p>Raw singletons make testing painful (you can’t swap them). Modern approach: use Dependency Injection (Hilt/Dagger) with @Singleton scope. Same one-instance guarantee, but injectable and testable.</p><h3>3. Factory — “Make Me One, I Don’t Care How”</h3><h4>The Problem</h4><p>Object creation is complicated, or you don’t know the exact type until runtime.</p><h4>The Solution</h4><p>Delegate creation to a separate method.</p><pre>// ViewModelProvider.Factory — you&#39;ve used this<br>class UserViewModelFactory(private val repo: UserRepository) : ViewModelProvider.Factory {<br>    override fun &lt;T : ViewModel&gt; create(modelClass: Class&lt;T&gt;): T {<br>        return UserViewModel(repo) as T<br>    }<br>}<br><br>// Fragment.newInstance() — another factory you&#39;ve seen<br>companion object {<br>    fun newInstance(userId: String) = UserFragment().apply {<br>        arguments = bundleOf(&quot;userId&quot; to userId)<br>    }<br>}</pre><p>Why Fragment.newInstance() and not a constructor? Because Android recreates Fragments using the no-arg constructor on rotation. The factory puts data in the arguments Bundle which survives recreation.</p><h3>4. Builder — “Give Me Options, Not a 15-Parameter Constructor”</h3><h4>The Problem</h4><p>An object has many optional parameters. The constructor becomes unreadable.</p><h4>The Solution</h4><pre>// You use this daily<br>AlertDialog.Builder(context)<br>    .setTitle(&quot;Delete?&quot;)<br>    .setMessage(&quot;This can&#39;t be undone&quot;)<br>    .setPositiveButton(&quot;Delete&quot;) { _, _ -&gt; delete() }<br>    .setNegativeButton(&quot;Cancel&quot;, null)<br>    .show()<br><br>OkHttpClient.Builder()<br>    .connectTimeout(30, TimeUnit.SECONDS)<br>    .addInterceptor(loggingInterceptor)<br>    .cache(cache)<br>    .build()<br><br>Retrofit.Builder()<br>    .baseUrl(&quot;https://api.example.com/&quot;)<br>    .addConverterFactory(GsonConverterFactory.create())<br>    .client(okHttpClient)<br>    .build()</pre><p>Notice how every method returns this (the builder itself) — that&#39;s what enables the chaining.</p><h3>5. Strategy — “Same Task, Different Approaches”</h3><h4>The Problem</h4><p>You have an operation that can be done in multiple ways, and you want to switch between them at runtime.</p><pre>// RecyclerView.LayoutManager IS the Strategy pattern<br>recyclerView.layoutManager = LinearLayoutManager(context)  // list<br>recyclerView.layoutManager = GridLayoutManager(context, 2) // grid<br><br>// Same RecyclerView. Different layout strategy. Zero code changes.<br><br>// Animation interpolators — same pattern<br>animator.interpolator = AccelerateInterpolator()  // speeds up<br>animator.interpolator = BounceInterpolator()      // bounces<br>animator.interpolator = LinearInterpolator()      // constant</pre><h4>The Solution</h4><p>Define a family of algorithms and make them interchangeable.</p><p>Custom example:</p><pre>interface SortStrategy {<br>    fun sort(items: List&lt;Item&gt;): List&lt;Item&gt;<br>}<br><br>class SortByPrice : SortStrategy {<br>    override fun sort(items: List&lt;Item&gt;) = items.sortedBy { it.price }<br>}<br><br>class SortByRating : SortStrategy {<br>    override fun sort(items: List&lt;Item&gt;) = items.sortedByDescending { it.rating }<br>}<br><br>// Switch sorting without touching the list code<br>productList.changeSorting(SortByPrice())</pre><h3>6. Adapter — “Make These Two Incompatible Things Work Together”</h3><h4>The Problem</h4><p>Two things need to connect but speak different languages. Like a US plug and a European socket.</p><h4>The Solution</h4><p>A wrapper that translates.</p><p>RecyclerView.Adapter is literally this pattern:</p><pre>// RecyclerView speaks &quot;ViewHolders&quot;<br>// Your data speaks &quot;List&lt;User&gt;&quot;<br>// The Adapter translates between them<br><br>class UserAdapter(private var users: List&lt;User&gt;) : RecyclerView.Adapter&lt;UserViewHolder&gt;() {<br><br>    override fun onBindViewHolder(holder: UserViewHolder, position: Int) {<br>        // RecyclerView gives a position → we translate to User<br>        holder.bind(users[position])<br>    }<br><br>    override fun getItemCount() = users.size<br>}</pre><p>RecyclerView doesn’t know what a User is. Your domain model doesn&#39;t know what a ViewHolder is. The adapter bridges them.</p><h3>7. Repository — “I Don’t Care Where the Data Comes From”</h3><h4>The Problem</h4><p>Your ViewModel needs users. They could come from the network, local database, or in-memory cache. The ViewModel shouldn’t know or care.</p><h4>The Solution</h4><p>One class abstracts all data sources.</p><pre>class UserRepository(<br>    private val api: UserApi,<br>    private val db: UserDao,<br>    private val cache: UserCache<br>) {<br>    suspend fun getUsers(): List&lt;User&gt; {<br>        // 1. Check cache<br>        cache.get()?.let { return it }<br><br>        // 2. Check local DB<br>        val local = db.getAll()<br>        if (local.isNotEmpty()) return local.also { cache.set(it) }<br><br>        // 3. Last resort: network<br>        val remote = api.fetchUsers()<br>        db.insertAll(remote)<br>        cache.set(remote)<br>        return remote<br>    }<br>}<br><br>// ViewModel is blissfully ignorant<br>class UserViewModel(private val repo: UserRepository) : ViewModel() {<br>    fun load() = viewModelScope.launch {<br>        _state.value = repo.getUsers()  // no idea where it came from<br>    }<br>}</pre><p>Swap the repo with a fake in tests. Switch from REST to GraphQL without touching the ViewModel. Add offline support by just changing the repository logic.</p><h3>8. Decorator — “Add Behavior Without Changing the Original”</h3><h4>The Problem</h4><p>You want to add logging, authentication, or caching to network calls — without modifying the core HTTP logic.</p><h4>The Solution</h4><p>Wrap the object in layers that each add one behavior.</p><p>OkHttp interceptors are pure Decorator pattern:</p><pre>val client = OkHttpClient.Builder()<br>    .addInterceptor(LoggingInterceptor())     // layer 1: logs<br>    .addInterceptor(AuthInterceptor(token))   // layer 2: adds auth header<br>    .addInterceptor(CacheInterceptor())       // layer 3: caches responses<br>    .build()</pre><p>Each interceptor wraps the call, adds its behavior, and passes it along:</p><pre>class AuthInterceptor(private val token: String) : Interceptor {<br>    override fun intercept(chain: Interceptor.Chain): Response {<br>        val original = chain.request()<br>        val withAuth = original.newBuilder()<br>            .addHeader(&quot;Authorization&quot;, &quot;Bearer $token&quot;)<br>            .build()<br>        return chain.proceed(withAuth)  // pass to next layer<br>    }<br>}</pre><p>The core HTTP request knows nothing about auth, logging, or caching. Each decorator adds one responsibility.</p><h3>The Cheat Sheet</h3><p>Stop memorizing definitions. Remember the problem:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tzsi5nkZmVTvyEyNH1uyBg.png" /></figure><h3>The Real Test</h3><p>You understand a pattern when you can explain it in one sentence to a non-developer:</p><ul><li>Observer: “It’s like a newsletter subscription — you sign up once and get updates automatically.”</li><li>Singleton: “It’s like there’s one printer in the office — everyone uses the same one.”</li><li>Factory: “It’s like ordering food — you tell the kitchen what you want, not how to cook it.”</li><li>Builder: “It’s like customizing a pizza — pick your base, add toppings one by one, then bake.”</li><li>Strategy: “It’s like GPS apps — same destination, but you pick fastest route, shortest, or no-tolls.”</li><li>Adapter: “It’s like a power adapter when traveling — same device, different socket.”</li><li>Repository: “It’s like a librarian — you ask for a book, you don’t care if it’s from the shelf, the basement, or another library.”</li><li>Decorator: “It’s like gift wrapping — same box inside, but each layer adds something (bow, ribbon, card).”</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40b46cd1e2af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The 4 Types of Offline Storage in Android: A Beginner’s Guide]]></title>
            <link>https://proandroiddev.com/the-4-types-of-offline-storage-in-android-a-beginners-guide-016dff24ae8b?source=rss-718ce0ca0016------2</link>
            <guid isPermaLink="false">https://medium.com/p/016dff24ae8b</guid>
            <category><![CDATA[android-architecture]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mobile-development]]></category>
            <dc:creator><![CDATA[Sehaj kahlon]]></dc:creator>
            <pubDate>Tue, 16 Jun 2026 02:58:08 GMT</pubDate>
            <atom:updated>2026-06-26T20:40:04.812Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g7QG4bjssjsH5SB9wui4KQ.png" /></figure><p>Imagine using your favorite app. You step into an elevator, lose your internet connection, and suddenly the screen goes blank. Frustrating, right?</p><p>Users expect apps to work seamlessly, regardless of network conditions. To achieve this, Android developers use <strong>offline caching</strong> — storing data locally on the device. However, not all data is created equal. You wouldn’t store a 50MB video file in the same place you store a user’s dark mode preference.</p><p>In modern Android development, there are four primary ways to store data locally. Let’s break them down using simple, real-world analogies so you can understand exactly when to use which.</p><h3>1. In-Memory Cache (The “Sticky Note”)</h3><p><strong>What it is:</strong> Storing data purely in the device’s RAM (Random Access Memory) while the app is actively running.</p><p><strong>The Analogy:</strong> Think of this as a sticky note on your desk. It is incredibly fast to write on and read from. However, the moment you leave the office (when the app closes or the Android system kills it to save memory), the cleaning staff throws the sticky note away.</p><p><strong>When to use it:</strong> For temporary data that you need right now, but won’t care about if the app restarts.</p><ul><li><strong>Real-world example:</strong> When a user is typing in a search bar, the app temporarily holds the search autocomplete suggestions. If they close the app, you don’t need to save those half-typed suggestions forever. Similarly, the loaded posts in a social media feed are kept in memory so the user can scroll up and down instantly without stuttering.</li></ul><p>💻 <strong>How it looks in code:</strong> Because this is just RAM, you don’t need any special Android libraries. You just use standard Kotlin variables, often held in a ViewModel or a Singleton object.</p><pre>// A simple object to hold data while the app is alive<br>object UserSessionCache {<br>    var activeSearchQuery: String = &quot;&quot;<br>    var temporaryFeedList: List&lt;String&gt; = emptyList()<br>}<br><br>// Saving data (Instant)<br>UserSessionCache.activeSearchQuery = &quot;Android caching&quot;<br><br>// Reading data (Instant)<br>val currentSearch = UserSessionCache.activeSearchQuery</pre><h3>2. Jetpack DataStore (The “Wallet”)</h3><p><strong>What it is:</strong> The modern replacement for SharedPreferences. It is designed to safely store small, simple pieces of data, usually as &quot;Key-Value&quot; pairs (like a label and its corresponding data). This data is saved permanently to the device&#39;s storage.</p><p><strong>The Analogy:</strong> Think of this as your wallet. You don’t put a whole textbook in your wallet; you put small, highly important cards in it — like your ID or a credit card. You take it out to quickly check a specific piece of information.</p><p><strong>When to use it:</strong> For small settings, preferences, and simple states.</p><ul><li><strong>Real-world example:</strong> A user toggles a switch to enable “Dark Mode.” You save a key called is_dark_mode with the value true. The next time they open the app, it quickly checks the wallet, sees true, and loads the dark theme.</li><li>Another common use is storing a small login token so the user doesn&#39;t have to type their password every single time.</li></ul><p>💻 <strong>How it looks in code:</strong> DataStore uses Kotlin Coroutines and Flows to read and write data safely in the background.</p><pre>// 1. Create the DataStore and define a Key<br>val Context.dataStore by preferencesDataStore(name = &quot;settings&quot;)<br>val DARK_MODE_KEY = booleanPreferencesKey(&quot;dark_mode&quot;)<br><br>// 2. Saving data (Writing)<br>suspend fun saveDarkModePreference(context: Context, isEnabled: Boolean) {<br>    context.dataStore.edit { preferences -&gt;<br>        preferences[DARK_MODE_KEY] = isEnabled<br>    }<br>}<br><br>// 3. Reading data (Listening for updates)<br>val darkModeFlow: Flow&lt;Boolean&gt; = context.dataStore.data.map { preferences -&gt;<br>    preferences[DARK_MODE_KEY] ?: false // &#39;false&#39; is the default if no data exists<br>}</pre><h3>3. Room Database (The “Filing Cabinet”)</h3><p><strong>What it is:</strong> Room is Android’s official, highly structured database toolkit (built over SQLite). It stores complex, relational data that needs to be queried, sorted, or filtered. Data here is also saved permanently.</p><p><strong>The Analogy:</strong> Think of Room as a massive, organized filing cabinet or a complex Excel spreadsheet. You have different folders (Tables) for different types of data, with specific formats (Columns) and individual records (Rows).</p><p><strong>When to use it:</strong> When you have large lists of structured data that relate to one another.</p><ul><li><strong>Real-world example:</strong> A messaging app storing chat history. You have a table for Messages with columns for Sender, Timestamp, and Text. Room lets the app easily execute commands like: <em>&quot;Show me the last 50 messages from John, sorted by time.&quot;</em></li><li>Another example is an e-commerce cart holding selected items while the user is offline, waiting to sync when the internet returns.</li></ul><p>💻 <strong>How it looks in code:</strong> Room requires you to define the “shape” of your data (Entity) and the commands you want to run (DAO).</p><pre>// 1. Define the Table (Entity)<br>@Entity(tableName = &quot;users&quot;)<br>data class User(<br>    @PrimaryKey val id: Int,<br>    val name: String,<br>    val email: String<br>)<br><br>// 2. Define the Commands (Data Access Object - DAO)<br>@Dao<br>interface UserDao {<br>    // Save a user to the database<br>    @Insert<br>    suspend fun insertUser(user: User)<br><br>    // Fetch all users from the database<br>    @Query(&quot;SELECT * FROM users&quot;)<br>    suspend fun getAllUsers(): List&lt;User&gt;<br>}</pre><h3>4. File Storage (The “Warehouse”)</h3><p><strong>What it is:</strong> The Android File System. Databases are great for text and numbers, but they are incredibly inefficient for holding raw, heavy binary data. For massive files, you save them directly to the device’s internal or external storage directories.</p><p><strong>The Analogy:</strong> Think of this as a physical warehouse. You wouldn’t try to stuff a bicycle into a filing cabinet (a database). Instead, you put the bicycle in the warehouse, write down its warehouse aisle number on a piece of paper, and put that paper in the filing cabinet.</p><p><strong>When to use it:</strong> For heavy media, documents, and raw files.</p><ul><li><strong>Real-world example:</strong> When a user clicks “Download” on a Spotify playlist, the app doesn’t stuff the audio into a database. It downloads the raw .mp3 files directly into the phone&#39;s storage. Similarly, when you download a PDF receipt or a WhatsApp image, it goes straight into File Storage.</li></ul><p>💻 <strong>How it looks in code:</strong> Android provides direct access to the file system. Here is the simplest way to write a basic file to the app’s internal (private) storage.</p><pre>// Saving data directly to a file<br>fun saveReceiptFile(context: Context, filename: String, fileContents: String) {<br>    // Open a file output stream in private mode<br>    context.openFileOutput(filename, Context.MODE_PRIVATE).use { stream -&gt;<br>        stream.write(fileContents.toByteArray())<br>    }<br>}<br><br>// Usage: <br>// saveReceiptFile(context, &quot;receipt_101.txt&quot;, &quot;Total: $50&quot;)</pre><h3>Summary Cheat Sheet</h3><p>If you ever get stuck deciding which storage to use, refer to this quick guide:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o0tPkzoG8M6YS8FD3zo1Fw.png" /></figure><p>Understanding these four layers is the foundation of building robust, offline-first Android applications. By picking the right tool for the job, you ensure your app is fast, respects the user’s storage limits, and provides a flawless experience — even in an elevator.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=016dff24ae8b" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/the-4-types-of-offline-storage-in-android-a-beginners-guide-016dff24ae8b">The 4 Types of Offline Storage in Android: A Beginner’s Guide</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond the Hype: The Pragmatic Developer’s Guide to AI Tools]]></title>
            <link>https://medium.com/@sehajkahlon437/beyond-the-hype-the-pragmatic-developers-guide-to-ai-tools-84667bed5ef4?source=rss-718ce0ca0016------2</link>
            <guid isPermaLink="false">https://medium.com/p/84667bed5ef4</guid>
            <category><![CDATA[artificalintelligence]]></category>
            <category><![CDATA[generative-ai]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[developer-productivity]]></category>
            <dc:creator><![CDATA[Sehaj kahlon]]></dc:creator>
            <pubDate>Sat, 13 Jun 2026 22:36:18 GMT</pubDate>
            <atom:updated>2026-06-13T22:36:18.532Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q27_e-xumnJPsVdxuiZQKw.png" /></figure><p>We use AI coding tools every day to tab-complete boilerplate or explain legacy code, but most of us still treat them like magic black boxes. And when you treat a tool like magic, you’re at its mercy when it fails.</p><p>As engineers, we wouldn’t use a database without understanding its query planner, or a framework without understanding its lifecycle. We need the same mental model for our AI tools.</p><p>This isn’t a marketing piece about 10x productivity. It’s a practical look under the hood at model architectures, context windows, and the real differences between chat, completions, and agents. Here is what actually happens when you press Tab.</p><h3>1. Models: What’s Actually Different Between Them</h3><h3>The Tiering System</h3><p>Every AI company ships models in tiers. This isn’t just marketing — it reflects real architectural differences:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IQjW1BuPnbHMrTIKgLnkTA.png" /></figure><p><strong>How they’re actually different internally:</strong></p><ul><li>Bigger models have more <strong>parameters</strong> (learned weights). Opus likely has 200B+ params, Haiku maybe 20–30B.</li><li>More parameters = more “memory slots” to encode world knowledge and reasoning patterns.</li><li>But inference cost scales roughly linearly with parameter count. 10x bigger = ~10x slower &amp; costlier.</li></ul><p><strong>When to use what:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q5pdGh--6_MQKRNeUwLVOA.png" /></figure><h3>Context Window — Why It Matters More Than You Think</h3><p>A 200K token context window means the model can “see” ~150K words at once. For code, that’s roughly <strong>50–80 files </strong>of average size.</p><p><strong>How it works internally:</strong></p><ul><li>The transformer computes <strong>attention</strong> between every token and every other token in the context.</li><li>Cost is O(n²) with context length (quadratic). 200K context is <em>expensive</em> per request.</li><li>Models don’t “remember” beyond the context window. Every API call starts fresh.</li></ul><p><strong>Practical implication: </strong>When a Copilot agent indexes your repo, it’s not feeding your entire codebase to the model. It uses <strong>embeddings + retrieval</strong> to pick the <em>relevant</em> files, then stuffs those into the context window. This is RAG (Retrieval-Augmented Generation).</p><h3>2. How an LLM Actually Works (Engineer-Level)</h3><pre>Input: &quot;Fix the null pointer in UserRepository.kt&quot;<br><br>Step 1: Tokenization<br>  → [&quot;Fix&quot;, &quot; the&quot;, &quot; null&quot;, &quot; pointer&quot;, &quot; in&quot;, &quot; User&quot;, &quot;Repository&quot;, &quot;.kt&quot;]<br>  <br>Step 2: Embedding<br>  → Each token becomes a 4096-dimensional vector<br>  <br>Step 3: Transformer layers (×96 for a large model)<br>  → Self-attention: each token &quot;looks at&quot; all other tokens<br>  → Figures out: &quot;null pointer&quot; relates to &quot;Fix&quot;, &quot;UserRepository.kt&quot; is the target<br>  → MLP layers: transforms representations<br>  <br>Step 4: Output head<br>  → Predicts probability distribution over ALL possible next tokens<br>  → Samples: &quot;The&quot; (p=0.3), &quot;In&quot; (p=0.2), &quot;Looking&quot; (p=0.15)...<br>  → Picks one based on temperature setting<br>  <br>Step 5: Repeat from Step 2 with the new token appended<br>  → Autoregressive generation, one token at a time</pre><p><strong>Key insight:</strong> The model doesn’t “understand” your code the way you do. It has learned statistical patterns over billions of code examples. When it “fixes a bug,” it’s pattern-matching against millions of similar bug-fix diffs it saw during training.</p><p><strong>Why this matters for you:</strong> The model is better at things that appeared frequently in training data.</p><p>Common patterns (MVVM, Room DB, Retrofit) → great results.</p><p>Novel architecture or internal proprietary frameworks → worse results unless you provide context.</p><h3>3. Agents vs. Chat vs. Completions — When to Use What</h3><h4>Completions (Inline / Tab-complete)</h4><p><strong>What it is: </strong>The model sees your current file + cursor position, and predicts what you’d type next.</p><p>Internal flow:</p><pre>Your code context (prefix + suffix around cursor)<br>    → sent to a small, fast model (Haiku-class)<br>    → generates 1-3 lines<br>    → shown as ghost text<br>    → latency budget: &lt;300ms</pre><p><strong>When it’s best:</strong> Boilerplate, repetitive patterns, finishing a line you started. It has minimal context (usually just the current file + a few related ones).</p><h4>Chat</h4><p><strong>What it is:</strong> You ask a question, the model answers. Stateless per request (history is re-sent each time).</p><p><strong>Internal flow:</strong></p><pre>System prompt + conversation history + your message<br>    → sent to a mid-tier model (Sonnet-class)<br>    → model generates a complete response<br>    → no actions taken on your codebase</pre><p><strong>When it’s best:</strong> Understanding code, asking “how does X work,” getting explanations, brainstorming approaches. Use when you want <em>information</em>, not <em>changes</em>.</p><h4>Agent Mode</h4><p><strong>What it is:</strong> An autonomous loop where the model can take actions.</p><p>Internal flow:</p><pre>while task not complete:<br>    1. Model receives: system prompt + tools available + conversation + tool results<br>    2. Model decides: &quot;I need to search for UserRepository.kt&quot;<br>    3. Tool executes: grep/file search runs, results returned<br>    4. Model receives results, decides next action<br>    5. Model: &quot;I&#39;ll edit line 45 to add null check&quot;<br>    6. Tool executes: file edit applied<br>    7. Model: &quot;Now I&#39;ll run tests to verify&quot;<br>    8. Tool executes: terminal runs ./gradlew test<br>    9. Model sees test output → done or iterate</pre><p><strong>When it’s best:</strong> Multi-file changes, refactoring, “implement this feature,” anything requiring multiple steps. The agent handles the tedious search → understand → edit → verify loop.</p><p><strong>Why it sometimes fails:</strong> Each iteration burns tokens. Complex tasks might need 10–20 tool calls. If the model makes a wrong assumption early, it compounds. That’s why giving good initial context matters.</p><h3>4. Tools, Function Calling, and MCP — The Plumbing</h3><h4>Function Calling (How Models Take Actions)</h4><p>The model doesn’t <em>actually</em> call functions. Here’s what happens:</p><pre>You: &quot;What&#39;s the weather in Bangalore?&quot;<br>Model output (not shown to you):<br>{<br>  &quot;tool_calls&quot;: [{<br>    &quot;name&quot;: &quot;get_weather&quot;,<br>    &quot;arguments&quot;: {&quot;city&quot;: &quot;Bangalore&quot;}<br>  }]<br>}<br>→ The HOST APPLICATION (Copilot/Claude app) sees this structured output<br>→ It executes the function<br>→ Returns result to model: {&quot;temp&quot;: 28, &quot;condition&quot;: &quot;cloudy&quot;}<br>→ Model generates: &quot;It&#39;s 28°C and cloudy in Bangalore.&quot;</pre><p><strong>Key insight:</strong> The model was <em>trained</em> to output these structured tool calls. It’s not running code — it’s generating JSON that the host application interprets.</p><h4>MCP (Model Context Protocol</h4><p><strong>Problem it solves:</strong> Every AI tool (Copilot, Cursor, Claude Desktop) was building its own proprietary plugin system. MCP standardizes this.</p><p>How it works:</p><pre>┌─────────────┐         ┌─────────────┐         ┌──────────────┐<br>│  AI Host    │  JSON   │  MCP Server │         │  External    │<br>│  (Copilot)  │◄──────► │  (process)  │◄───────►│  Service     │<br>│             │  stdio/ │             │  HTTP/  │  (Figma/DB/  │<br>│             │  HTTP   │             │  SDK    │   Jira/etc)  │<br>└─────────────┘         └─────────────┘         └──────────────┘</pre><p>An MCP server exposes <strong>tools (actions)</strong>, <strong>resources (data),</strong> and <strong>prompts (templates)</strong> over a standard protocol. Any AI client that speaks MCP can use any MCP server.</p><p><strong>Analogy:</strong> MCP is to AI tools what REST is to web APIs — a standard interface so any client can talk to any server.</p><p><strong>When you’d use it: </strong>Want Copilot to query your internal API, read from a Figma file, or interact with your CI system? Write or install an MCP server.</p><h3>5. RAG vs. Fine-tuning vs. Prompting — Decision Framework</h3><p><strong>This is the most practical question:</strong> how do I make AI work better for my specific codebase/domain?</p><pre>┌────────────────────────────────────────────────────────────────────┐<br>│                    DECISION TREE                                   │<br>├────────────────────────────────────────────────────────────────────┤<br>│                                                                    │<br>│  &quot;AI doesn&#39;t know about X&quot;                                         │<br>│        │                                                           │<br>│        ├── Is X public knowledge but model gets it wrong?          │<br>│        │      → Better prompting (few-shot examples, instructions) │<br>│        │                                                           │<br>│        ├── Is X private/recent data the model never saw?           │<br>│        │      → RAG (retrieve docs, feed into context)             │<br>│        │                                                           │<br>│        ├── Do you need consistent style/behavior change?           │<br>│        │      → Fine-tuning (teach the model your patterns)        │<br>│        │                                                           │<br>│        └── Do you need entirely new capabilities?                  │<br>│               → Train from scratch (rarely needed, very expensive) │<br>│                                                                    │<br>└────────────────────────────────────────────────────────────────────┘</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tyLlit1ZOOBELIk5KwJ6gg.png" /></figure><p><strong>For your specific codebase:</strong> RAG + good prompting (via copilot-instructions.md) is likely all you need. Fine-tuning only makes sense if you want a model that writes your proprietary code style without being told.</p><h3>6. Copilot Specifics — What’s Actually Happening</h3><h4>Skills</h4><p>A skill is a hardcoded capability that the Copilot agent can invoke. When you say “create a new project,” it doesn’t freestyle — it reads a predefined SKILL.md file with scaffolding instructions.</p><p>Think of it as: if (user_intent matches &quot;project setup&quot;) → load(skill_template) → follow those steps</p><h4>Hooks</h4><p>Hooks are scripts YOU define that run at specific points:</p><pre># .vscode/copilot-hooks.json<br>{<br>  &quot;postFileEdit&quot;: &quot;npm run lint --fix ${file}&quot;,<br>  &quot;preCommit&quot;: &quot;npm test&quot;<br>}</pre><p><strong>When useful:</strong> Auto-formatting after Copilot edits, running tests before accepting changes, enforcing your team’s standards automatically.</p><h4>Instructions Files</h4><pre>.github/copilot-instructions.md     → repo-wide rules<br>.vscode/copilot-instructions.md     → workspace rules</pre><p>These get injected into the system prompt. This is how you tell Copilot: “We use MVVM, our DI is Koin not Hilt, always use Result&lt;T&gt; for error handling.&quot;</p><h3>7. Temperature, Sampling, and Why AI Outputs Vary</h3><pre>// Simplified model output at each step:<br>tokens:     [&quot;fun&quot;, &quot;get&quot;, &quot;User&quot;, &quot;(&quot;, &quot;id&quot;, &quot;:&quot;, &quot; Int&quot;, &quot;)&quot;]<br>probs:      [0.4,   0.3,  0.15,  ...]  // for next token after each<br>// Temperature = 0: always pick highest probability → deterministic<br>// Temperature = 0.7: softmax with scaling → some randomness<br>// Temperature = 1.5: very flat distribution → creative/chaotic</pre><p>Why coding uses low temperature (0–0.3): Code has one correct answer. You want getUserById(id: Int): User? not a creative alternative.</p><p>Why creative writing uses high temperature (0.8–1.2): You want variety and surprise.</p><p>Top-p (nucleus sampling): Instead of temperature, cut off low-probability tokens. “Only consider tokens that together make up 95% of probability mass.” Prevents truly random garbage while allowing variety.</p><h3>8. Practical Decision Matrix: Which AI Tool When</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iAN-NZ0dnE25U6fyvJxSWg.png" /></figure><h3>9. What’s Happening When “AI is Slow” or “AI Gets It Wrong”</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s7nF67urpzgloYij7pb3vw.png" /></figure><h3>The Bottom Line: AI is Plumbing, Not Magic</h3><p>Once you strip away the hype, an LLM is just a highly advanced statistical pattern-matching engine. It doesn’t “think” about your codebase — it calculates the most likely next token based solely on the context you feed it.</p><p>Understanding this plumbing is what makes you a power user. You stop getting mad when it hallucinates, and instead fix the context. You stop waiting for a massive model to write a one-liner, and switch to a lightweight model.</p><p><strong>Your next step:</strong> Open your IDE today and create an instructions file (like .github/copilot-instructions.md). Write down three non-negotiable architectural rules for your codebase, and watch how much better the AI gets when it actually has the right context.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84667bed5ef4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kotlin File Types in Android Studio Explained: Class, Interface, Data Class, Object, Enum, and More]]></title>
            <link>https://medium.com/@sehajkahlon437/kotlin-file-types-in-android-studio-explained-class-interface-data-class-object-enum-and-more-dd2d96c51e72?source=rss-718ce0ca0016------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd2d96c51e72</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Sehaj kahlon]]></dc:creator>
            <pubDate>Thu, 11 Jun 2026 19:43:31 GMT</pubDate>
            <atom:updated>2026-06-11T19:43:31.624Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Hkow0-CCOdK231uwNht6Q.png" /></figure><p>When you create a new Kotlin file in Android Studio, you may see options like:</p><p>Class, Interface, Data Class, Enum Class, Annotation Class, Kotlin Script, Object, and File.</p><p>If you are new to Kotlin or Android development, this menu can feel confusing. Which one should you choose? What is the difference between a class and a data class? When should you use an object? What even is an annotation class?</p><p>By the end of this article, you will know exactly what each option means and when to use it in real Android projects.</p><h4>First, What is Android Studio Asking You?</h4><p>When you select <strong>New &gt; Kotlin Class/File</strong>, Android Studio is not just asking for a file name.</p><p>It is asking:</p><blockquote>What kind of Kotlin declaration do you want to create inside this file?</blockquote><p>All of these options create Kotlin code, but they create different starting structures.</p><p>For example:</p><pre>Class UserRepository</pre><p>is different from:</p><pre>data class User</pre><p>and both are different from:</p><pre>object AppConstants</pre><p>Each one has a specific purpose.</p><p>Let’s understand them one by one.</p><h3>1. File</h3><p>A File creates a plain Kotlin .kt file.</p><p>It does not automatically create a class, interface, or object.</p><p>Example:</p><pre>// StringExtensions.kt<br><br>fun String.maskPhoneNumber(): String {<br>return this.takeLast(4).padStart(length, &#39;*&#39;)<br>}</pre><p>In Kotlin, a file can directly contain:</p><ul><li>Functions</li><li>Constants</li><li>Extension functions</li><li>Multiple small declarations</li></ul><p>Example:</p><pre>const val MAX_RETRY_COUNT = 3<br><br>fun formatAmount(amount: Int): String {<br>return &quot;Rs. $amount&quot;<br>}</pre><h4>When should you use File?</h4><p>Use <strong>File</strong> when u do not need a class.</p><p>It is useful for:</p><ul><li>Utility Functions</li><li>Extension functions</li><li>Constants</li><li>Helper methods</li></ul><p>For example, in Android Projects, you may create</p><pre>//ViewExtensions.kt<br><br>fun View.show() {<br>visibility = View.VISIBLE<br>}<br><br>fun View.hide() {<br>visibility = View.GONE<br>}</pre><p>So if your code is just a set of helper functions, choose <strong>File</strong>.</p><h3>2. Class</h3><p>A <strong>class</strong> is one of the most commonly used options.</p><p>A class is like a blueprint for creating objects.</p><p>Example:</p><pre>Class UserRepositoty{}</pre><p>A class can have properties and functions:</p><pre>Class UserRepositoty(private cal apiService: ApiService){<br>fun getUser(){<br>//Fetch user from API<br>}<br>}</pre><h4>When should you use class?</h4><p>Use Class when you need logic, behaviour, or state.</p><p>Common Android examples include:</p><ul><li>Repository classes</li><li>Use cases</li><li>Managers</li><li>Adapters</li><li>Helpers</li><li>Custom Views</li><li>Services</li></ul><p>Example:</p><pre>class LoginUseCase( private val autRepository: AuthRepository){<br>suspended fun execure(phoneNumber: String): LoginResult{<br>return authRepository.login(phoneNumber)<br>}<br>}</pre><p>Here, LoginUseCase is not just holding data. It performs an action. That is why a normal class makes sense.</p><h4>Simple Rule</h4><p>If your file is going to contain business logic or behaviour, choose <strong>Class</strong>.</p><h3>3. Interface</h3><p>An <strong>Interface</strong> defines a contract.</p><p>It tells what something should do, but not necessarily how it should do it.</p><p>Example:</p><pre>interface userRepository{<br>suspend fun getUser(): User<br>}</pre><p>This means any class that implements UserRepository must provide a getUser() function.</p><p>Example implementation:</p><pre>class UserRepositoryImple(<br>private val apiService: ApiService): UserRepository{<br>override suspend fun getUser(): User { <br>return apiService.fetchUser()<br>}<br>}</pre><h4><strong>When should you use interface?</strong></h4><p>Use Interface when you want to define rules or behaviour that other classes must follow.</p><p>It is useful when:</p><ul><li>You want abstractions</li><li>You want multiple implementations</li><li>You want easier unit testing</li><li>You want to separate contracts from implementation</li></ul><p>Example:</p><pre>interface PaymentRepository{<br>suspend fun fetchOffers(): List&lt;Offer&gt;<br>}</pre><p>Then you can have one real implementation:</p><pre>class PaymentRepositoryImpl: PaymentRepository{<br>override suspend fun fetchOffers(): List&lt;Offer&gt;{<br>//Real APi call<br>return emptyList()<br>}<br>}</pre><p>And one fake implementation for testing:</p><pre>class FakePaymentRepository: PaymentRepository{<br>override suspended fun fetchOffers(): List&lt;Offer&gt;{<br>return listOf()<br>}<br>}</pre><h4>Simple Rule</h4><p>Use Interface when you want to say:</p><blockquote>Any class of this type must provide these functions.</blockquote><h3>4. Data Class</h3><p>A Data Class is a special type of class used mainly for holding data.</p><p>Example:</p><pre>data class User(<br>val id: String,<br>val name: String,<br>val phoneNumber: String<br>)</pre><p>Data classes are very common in Android Development.</p><p>They are used for:</p><ul><li>Api response model</li><li>Request model</li><li>UI State</li><li>Database entities</li><li>Screen data</li><li>Domain model</li></ul><p>Example:</p><pre>data class Offer(<br>val id: String,<br>val title: String,<br>val discountAmount: Int<br>)</pre><h4>What Makes Data Class Special?</h4><p>Kotlin automatically gives data classes useful functions like:</p><ul><li>toString()</li><li>equals()</li><li>hashCode()</li><li>copy()</li></ul><p>For example:</p><pre>data class LoginUiState(<br>val isLoading: Boolean = false,<br>val phoneNumber: String = &quot;&quot;,<br>val errorMessage: String? = null<br>)</pre><p>Then you can update only one value:</p><pre>val newState = oldState.copy(isLoading = true)</pre><h4>When should you use Data classes?</h4><p>Use Data Class when your class is mainly used to store values.</p><p>Good examples:</p><pre>data class Product(<br>val id: String,<br>val name: String,<br>val price: Dobule<br>)</pre><h4>Simple Rule</h4><p>If the main purpose is to hold data, choose Data class.</p><h3>5. Enum Class</h3><p>An Enum Class is used when a value can be one from a fixes list of options.</p><p>Example:</p><pre>enum class PaymentStatus{<br>SUCCESS,<br>FAILED,<br>PENDING<br>}</pre><p>Here, PaymentStatus can only be:</p><ul><li>SUCCESS</li><li>FAILED</li><li>PENDING</li></ul><p>Nothing else.</p><h4>When should you use Enum Class?</h4><p>Use Enum Class when you have a fixed set of possible values.</p><p>Common example:</p><pre>enum class ScreenState{<br>LOADING,<br>SUCCESS,<br>ERROR<br>}</pre><pre>enum class OfferType{<br>CASHBACK,<br>DISCOUNT,<br>REWARD<br>}</pre><p>This is better than using random string like:</p><pre>val status = &quot;success&quot;</pre><p>Why? Because strings can easily cause bugs:</p><pre>val status = &quot;succes&quot; //typo</pre><p>With enum class, Kotlin protects you from invalid values.</p><h4><strong>Simple Rule</strong></h4><p>Use <strong>Enum Class</strong> when you have a small, fixed list of possible values.</p><h3>6. Annotation Class</h3><p>An <strong>Annotation Class </strong>is used to create custom annotations.</p><p>You may have already seen annotations in Android:</p><pre>@Inject<br>@Test<br>@Composable<br>@SerializedName(&quot;user_Name&quot;)</pre><p>Annotations add extra information or metadata to code.</p><p>A custom annotation looks like this:</p><pre>annotation class FeatureFlag(val name: String)</pre><p>You can use it like this:</p><pre>@FeatureFlag(&quot;new_payment_flow&quot;)<br>class NewPaymentFlow</pre><p>When should you use Annotation Class?</p><p>Honestly, not very often as a beginner.</p><p>Annotation classes are mostly used when working with:</p><ul><li>Frameworks</li><li>Code generation</li><li>Dependency injection</li><li>Testing tools</li><li>Serialization</li><li>Custom tooling</li></ul><p>Most Android developers use existing annotations more often than they create new ones.</p><p><strong>Simple Rule</strong></p><p>Choose <strong>Annotation Class</strong> only when you specifically need to create your own annotation.</p><p>If you are unsure, you probably do not need it yet.</p><h3>7. Kotlin Script</h3><p>A Kotlin script creates a .kts file.</p><p>You have probably seen this in Gradle files:</p><pre>build.gradle.kts</pre><p>Kotlin scripts are used for code that runs like a script, usually for configuration or automation.</p><p>Example:</p><pre>println(&quot;Hello from kotlin script&quot;)</pre><h4>When should you use Kotlin script?</h4><ul><li>Gradle build files</li><li>Automation scripts</li><li>Configuration scripts</li><li>Tooling scripts</li></ul><p>In regular Android app development, you usually do not choose this for screens, repositories, models, or business logic.</p><p><strong>Simple Rule</strong></p><p>Use Kotlin Script for build or automation work, not normal app code.</p><h3>8. Object</h3><p>An Object in Kotlin creates a singleton.</p><p>Singleton means there is only one instance of it in the entire app.</p><p>Example:</p><pre>object AppConstants{<br>const val a = &quot;A&quot;<br>const val b = &quot;B&quot;<br>}</pre><p>You do not create it like this:</p><pre>val constants = AppConstants()</pre><p>Instead, you directly use it:</p><pre>AppConstants.a</pre><p>When should you use an object?</p><p>Use an object when you need exactly one shared instance.</p><p>Common Examples:</p><pre>object Routes{<br>const val HOME = &quot;home&quot;<br>const val PROFILE = &quot;profile&quot;<br>}</pre><p>Be Careful with Objects</p><p>Do not use objects for everything.</p><p>For example, repositories and services are often better created using dependency injection because it makes testing easier.</p><h4>Simple Rule</h4><p>Use objects when there should be only shared things, like constants or stateless utilities.</p><h4>Which One Should You Choose?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BLIKovmb76igdafrwRwYFw.png" /></figure><h4>Final Recommendation</h4><p>Just remember this:</p><ul><li>Use <strong>Data Class</strong> for data</li><li>Use <strong>Class</strong> for logic</li><li>Use <strong>an interface</strong> for contracts</li><li>Use <strong>Enum Classes</strong> for fixed choices</li><li>Use <strong>object</strong> for single shared instances</li><li>Use <strong>File</strong> for utility or extension functions</li><li>Use <strong>Kotlin Script</strong> for build/config scripts</li><li><strong>Use Annotation Class</strong> only for advanced custom annotations.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd2d96c51e72" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>