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 exactDocumentation 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.
app/build.gradle.kts configuration used in the Lottie Android Kotlin Demo and explains what each setting does.
Android Block Configuration
Theandroid { } 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
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
ThecompileOptions block pins both the Java source language level and the bytecode target level to Java 11:
app/build.gradle.kts
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
Therelease build type is tuned for a production APK or AAB:
app/build.gradle.kts
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 files —
proguard-android-optimize.txtis the baseline AGP ruleset;proguard-rules.prois where project-specific keep rules live (important for Lottie if you reference animation names reflectively). jniLibs.useLegacyPackaging = false— Stores native.solibraries 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.MainActivity.kt:
MainActivity.kt
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