Overview
TechSales uses Gradle build types to create different versions of the app for development and production. Build types control code optimization, debugging capabilities, and security features.Build Configuration
Build types are defined inapp/build.gradle.kts:
app/build.gradle.kts
Default Configuration
Application Identity
The app’s package namespace used for R class generation and AndroidManifest merging.Value:
com.teamtech.techsalesUnique identifier for the app on the device and in the Play Store.Value:
com.teamtech.techsalesnamespace and applicationId can be different, but they typically match. The namespace is for code organization, while applicationId identifies the app at runtime.SDK Versions
Android SDK version used for compilation. Uses SDK 36 with minor API level 1.Value:
release(36) { minorApiLevel = 1 }Minimum Android version required to run the app.Value:
29 (Android 10)Android version the app is designed to run on. Determines which platform behaviors apply.Value:
36Version Information
Internal version number. Must increase with each release for Play Store updates.Value:
1User-facing version string displayed to users.Value:
"1.0"Increment
versionCode for every release (even internal builds). Use semantic versioning for versionName (e.g., “1.0.0”, “1.1.0”, “2.0.0”).Test Configuration
Test runner for instrumented tests.Value:
androidx.test.runner.AndroidJUnitRunnerBuild Types
Debug Build (Default)
The debug build type is automatically created by Android Gradle Plugin with these defaults:- Debugging enabled
- No code obfuscation
- Faster build times
- Signed with debug keystore
- Can be installed alongside release builds
- Local development
- Testing on devices
- Debugging with Android Studio
- CI/CD test builds
Release Build
The release build type is explicitly configured:app/build.gradle.kts
Controls code shrinking and obfuscation using R8/ProGuard.Current Value:
Recommended for Production:
falseRecommended for Production:
trueProGuard/R8 configuration files for code optimization and obfuscation.
ProGuard Configuration
Default ProGuard File
proguard-android.txt- Basic rules without aggressive optimizationsproguard-android-optimize.txt- Includes optimization rules (recommended)
Custom ProGuard Rules
Createapp/proguard-rules.pro for custom rules:
proguard-rules.pro
ProGuard rules are only applied when
isMinifyEnabled = true. They have no effect in the current configuration.Enabling Code Optimization
For production releases, enable minification:Removes unused resources from the APK when enabled. Requires
isMinifyEnabled = true.- Smaller APK Size - Reduces download size by 30-50%
- Faster Performance - Optimized bytecode runs more efficiently
- Better Security - Obfuscated code is harder to reverse engineer
- Reduced Method Count - Removes unused methods and classes
Compile Options
app/build.gradle.kts
Java language version for source code.Value: Java 11
Java bytecode version for compiled classes.Value: Java 11
Java 11 is the minimum version required for Android Gradle Plugin 8.0+. It enables modern Java features like
var, lambda improvements, and HTTP client.Building the App
Debug Build
app/build/outputs/apk/debug/app-debug.apk
Release Build
- APK:
app/build/outputs/apk/release/app-release.apk - AAB:
app/build/outputs/bundle/release/app-release.aab
Google Play requires Android App Bundles (.aab) for new apps. AAB files are smaller and enable dynamic delivery features.
Signing Configuration
Debug Signing
Debug builds are automatically signed with the debug keystore:- Location:
~/.android/debug.keystore - Password:
android - Alias:
androiddebugkey - Alias Password:
android
Release Signing
For production releases, configure a release keystore:app/build.gradle.kts
~/.gradle/gradle.properties:
Build Variants
Build variants combine build types with product flavors. TechSales currently has:- debug - Debug build type
- release - Release build type
Adding Product Flavors
Create multiple app versions (e.g., free/paid, dev/staging/prod):- devDebug, devRelease
- stagingDebug, stagingRelease
- productionDebug, productionRelease
Build Performance
Optimization Tips
- Enable Build Cache
gradle.properties
- Enable Parallel Execution
gradle.properties
- Increase Memory
gradle.properties
- Use Configuration Cache
gradle.properties
Build Time Comparison
| Build Type | Minification | Typical Time |
|---|---|---|
| Debug | Disabled | 10-30s |
| Release | Disabled | 15-40s |
| Release | Enabled | 30-90s |
The first build after clean is slower. Subsequent builds use cached outputs and are significantly faster.
Recommended Production Configuration
For production releases, use this configuration:app/build.gradle.kts
Analyzing Build Output
APK Size Analysis
Dependency Tree
Build Scan
Common Issues
ProGuard/R8 Errors
Problem: App crashes in release build but works in debug. Solution: Add ProGuard keep rules for classes causing issues:Signing Errors
Problem: “Could not find signing config ‘release’” Solution: Ensure signing config is defined before build types reference it.Duplicate Classes
Problem: “Duplicate class found in modules…” Solution: Exclude conflicting dependencies:Related Documentation
- Gradle Configuration - Gradle setup and project structure
- Dependencies - Managing project dependencies
- Deployment - Publishing to Google Play Store