Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tutosrive/lottie-kt-test/llms.txt

Use this file to discover all available pages before exploring further.

Before you can render Lottie animations, your Android project needs to be configured with the right namespace, SDK versions, compile options, and release build settings. This guide walks through the exact app/build.gradle.kts configuration used in the Lottie Android Kotlin Demo and explains what each setting does.

Android Block Configuration

The android { } block in app/build.gradle.kts defines the core identity and compatibility targets for the app. Here is the full block used in this project:
app/build.gradle.kts
android {
    namespace = "com.srm.lottiee"
    compileSdk {
        version = release(37) {
            minorApiLevel = 1
        }
    }

    defaultConfig {
        applicationId = "com.srm.lottiee"
        minSdk = 24
        targetSdk = 36
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            isMinifyEnabled = true
            isShrinkResources = true
//            isShrinkResources = false // Just in AAB Release
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )

            packaging {
                jniLibs {
                    useLegacyPackaging = false
                }
            }
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
}
Key settings at a glance:
  • namespace = "com.srm.lottiee" — The unique package identifier for all generated R and BuildConfig classes. It must be unique across every app on a device.
  • minSdk = 24 — The lowest Android API level (Android 7.0 Nougat) the app supports. The Lottie library itself supports API 16+, so this is intentionally conservative.
  • targetSdk = 36 — Declares that the app has been tested against API 36 (Android 16) and opts in to all behaviour changes introduced up to that level.
  • compileSdk — Uses a release API level (release(37)) so the project compiles against the latest stable platform APIs.

Compile Options

The compileOptions block pins both the Java source language level and the bytecode target level to Java 11:
app/build.gradle.kts
compileOptions {
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11
}
Java 11 source compatibility enables language features such as local-variable type inference (var) and several newer API additions while remaining compatible with every device that meets the minSdk = 24 floor (D8/R8 desugars the bytecode at build time).

Release Build Type

The release build type is tuned for a production APK or AAB:
app/build.gradle.kts
release {
    isMinifyEnabled = true
    isShrinkResources = true
//            isShrinkResources = false // Just in AAB Release
    proguardFiles(
        getDefaultProguardFile("proguard-android-optimize.txt"),
        "proguard-rules.pro"
    )

    packaging {
        jniLibs {
            useLegacyPackaging = false
        }
    }
}
  • isMinifyEnabled = true — Activates R8, which shrinks and obfuscates the bytecode.
  • isShrinkResources = true — Strips unused resource files from the final artifact, reducing APK size. Note: this must be disabled when building an AAB if you rely on dynamic delivery.
  • ProGuard filesproguard-android-optimize.txt is the baseline AGP ruleset; proguard-rules.pro is where project-specific keep rules live (important for Lottie if you reference animation names reflectively).
  • jniLibs.useLegacyPackaging = false — Stores native .so libraries uncompressed inside the APK/AAB so the OS can load them directly from the archive without extracting them first, reducing install-time storage.

Edge-to-Edge Display

This project calls enableEdgeToEdge() in MainActivity to render content behind the system bars (status bar and navigation bar). You must also apply window insets as padding so your UI is not obscured by those bars.
The relevant code in MainActivity.kt:
MainActivity.kt
enableEdgeToEdge()
setContentView(R.layout.activity_main)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
    val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
    v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
    insets
}
enableEdgeToEdge() is an AndroidX helper (available from androidx.activity:activity:1.8+) that sets the window flags needed to draw behind system bars. The ViewCompat.setOnApplyWindowInsetsListener callback translates the inset values into padding on the root ConstraintLayout (@+id/main), preventing the animation and button from sitting underneath the status or navigation bar.
Next, add the Lottie library to your project: Adding the Lottie Dependency

Build docs developers (and LLMs) love