Teknasyon Mar 2, 2026

Using Gradle in Android: Build Variants, Build Types, and Manifest Placeholders

M2 Related OWASP risk: Inadequate Supply Chain Security Learn more →

Article Summary

Enes İğneci from Teknasyon Engineering breaks down the Gradle configuration secrets that separate amateur Android builds from production-ready apps. If you've ever shipped the wrong API key to production, this one's for you.

Managing multiple environments (dev, staging, production) in Android requires mastering three Gradle features most developers underutilize. This practical guide walks through build variants, build types, and manifest placeholders with real code examples using Kotlin DSL.

Key Takeaways

Critical Insight

Proper Gradle configuration eliminates hardcoded credentials and enables safe multi-environment testing on a single device.

The article reveals a specific Android Studio dialog that makes build variant setup visual instead of code-only.

About This Article

Problem

Android developers often struggle to keep testing, staging, and production environments separate. It's easy to accidentally ship the wrong credentials or API keys to the wrong deployment target.

Solution

Enes İğneci uses Gradle's flavorDimensions and productFlavors to create stage and prod variants. Each variant has its own applicationIdSuffix and manifestPlaceholders that inject the right ANALYTICS_API_KEY at build time.

Impact

Developers can build and install multiple app variants on one device at the same time. The com.enesigneci.playground.stage and com.enesigneci.playground bundle IDs each get their own auto-generated gradleResValues.xml file with the correct BASE_URL for that environment.