Skip to main content
This guide covers building and running the Kafka project in different configurations.

Build Configuration

Kafka uses Gradle with Kotlin DSL for build configuration. The project is configured with:
  • Compile SDK: 36
  • Min SDK: 24 (Android 7.0)
  • Target SDK: 34 (Android 14)
  • Java Version: 17
  • Kotlin: 2.3.0

Build Types

Kafka supports multiple build types defined in app/build.gradle.kts:

Debug Build

The debug build is optimized for development:
debug {
    signingConfig = signingConfigs["debug"]
    versionNameSuffix = "-dev"
    applicationIdSuffix = ".debug"
}
  • Application ID: com.kafka.user.debug
  • Minification: Disabled
  • Debuggable: Yes
# Build debug APK
./gradlew assembleDebug

# Install and run debug build
./gradlew installDebug

Release Build

The release build is optimized for production with code shrinking and obfuscation:
release {
    signingConfig = signingConfigs["debug"]
    isShrinkResources = true
    isMinifyEnabled = true
    proguardFiles("proguard-rules.pro")
}
# Build release APK
./gradlew assembleRelease

# Build release bundle (for Play Store)
./gradlew bundleRelease
Release builds use R8 full mode for aggressive code shrinking. Build times will be significantly longer than debug builds.

RC (Release Candidate) Build

For testing release builds before production:
create("rc") {
    initWith(buildTypes["release"])
    signingConfig = signingConfigs["debug"]
    versionNameSuffix = "-rc"
    applicationIdSuffix = ".rc"
}
  • Application ID: com.kafka.user.rc
  • Minification: Enabled
  • Allows side-by-side installation with debug and release builds
./gradlew assembleRc

Benchmark Build

Optimized for performance testing:
create("benchmark") {
    initWith(buildTypes["release"])
    signingConfig = signingConfigs["debug"]
    matchingFallbacks += "release"
    proguardFiles("proguard-rules.pro")
}
./gradlew assembleBenchmark

Running the App

From Android Studio

1

Select Build Variant

  1. Click Build > Select Build Variant in the menu
  2. Choose your desired build variant (debug, release, rc, or benchmark)
  3. Select the appropriate variant for the app module
2

Run Configuration

  1. Ensure your device or emulator is connected
  2. Select the target device from the device dropdown
  3. Click the Run button (green play icon) or press Shift+F10

From Command Line

# Install debug build and launch
./gradlew installDebug
adb shell am start -n com.kafka.user.debug/.MainActivity

# Or use the run task
./gradlew runDebug

Build Output Location

Built APKs and bundles are located in:
app/build/outputs/
├── apk/
│   ├── debug/
│   │   └── app-debug.apk
│   ├── release/
│   │   └── app-release.apk
│   ├── rc/
│   │   └── app-rc.apk
│   └── benchmark/
│       └── app-benchmark.apk
└── bundle/
    └── release/
        └── app-release.aab

Gradle Tasks

Common Tasks

# Clean build outputs
./gradlew clean

# Clean and rebuild
./gradlew clean assembleDebug

Module-Specific Builds

Build specific modules:
# Build a specific module
./gradlew :ui:homepage:assembleDebug

# Build all modules
./gradlew assembleDebug

# List all tasks for a module
./gradlew :app:tasks

Compose Compiler Metrics

To generate Compose compiler metrics and reports:
./gradlew assembleDebug -Ptivi.enableComposeCompilerReports=true
Reports will be generated in:
build/compose_metrics/
├── <module>-composables.txt
├── <module>-classes.txt
└── <module>-module.json
Compose compiler reports help identify optimization opportunities in your Composable functions.

Baseline Profiles

Kafka uses baseline profiles for improved app startup and runtime performance:
# Generate baseline profile
./gradlew :baselineprofile:generateBaselineProfile

# Generate using connected device
./gradlew :baselineprofile:generateBaselineProfile -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile
The baseline profile configuration uses a Pixel 6 API 31 managed device or any connected device.

Optimization Settings

ProGuard/R8 Rules

Release builds use R8 for code shrinking and obfuscation. Custom rules are defined in app/proguard-rules.pro. Key settings from gradle.properties:
# Enable R8 full mode for aggressive optimization
android.enableR8.fullMode=true

# Optimize resources
android.enableResourceOptimizations=true

# Disable unused build features
android.defaults.buildfeatures.resvalues=false
android.defaults.buildfeatures.shaders=false

Build Performance

Optimize build performance with these settings (already configured):
# Gradle daemon settings
org.gradle.jvmargs=-Xmx6020m -Dfile.encoding=UTF-8
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configureondemand=true

# Kotlin incremental compilation
kapt.use.worker.api=true
kapt.incremental.apt=true

CI/CD Build

The project includes a GitHub Actions workflow for automated builds. Reference: .github/workflows/build-release.yml Key CI steps:
1

Checkout Code

Both Kafka and Sarahang repositories are checked out
2

Setup JDK 17

Uses Temurin distribution with Gradle caching
3

Configure Secrets

  • Google Services JSON
  • Release keystore
  • API tokens from environment variables
4

Build Release

./gradlew assembleRelease

Troubleshooting

Build Failures

Ensure Sarahang is cloned in the parent directory:
cd ..
ls -la  # Should show both Kafka/ and Sarahang/
Increase Gradle memory allocation in gradle.properties:
org.gradle.jvmargs=-Xmx8192m -Dfile.encoding=UTF-8
Clean and rebuild:
./gradlew clean
./gradlew assembleDebug --refresh-dependencies
  • Enable parallel builds (already configured)
  • Use Gradle daemon (already configured)
  • Consider using configuration cache
  • Close other applications to free memory

Next Steps

Testing

Learn about testing strategies

Contributing

Contribute to the project

Build docs developers (and LLMs) love