Skip to content

Building the Project

This guide covers how to build the Cryptographer application for different environments.

Build Types

The project supports two build types:

  • Debug: Development build with debugging enabled
  • Release: Production build with optimizations

Building from Command Line

Debug Build

./gradlew assembleDebug

The APK will be generated at:

app/build/outputs/apk/debug/app-debug.apk

Release Build

./gradlew assembleRelease

The APK will be generated at:

app/build/outputs/apk/release/app-release.apk

Signing Required

Release builds require a signing configuration. See Configuration for details.

Building from Android Studio

  1. Select Build → Make Project (or press Ctrl + F9)
  2. For APK: Build → Build Bundle(s) / APK(s) → Build APK(s)
  3. Wait for the build to complete

Build Variants

The project currently has a single build variant. To check available variants:

./gradlew tasks --all | grep assemble

Running Tests

Unit Tests

./gradlew test

Test reports are available at:

app/build/reports/tests/test/index.html

Android Instrumented Tests

./gradlew connectedAndroidTest

Requires a connected device or running emulator.

Code Quality Checks

Format Code

./gradlew spotlessApply

Check Formatting

./gradlew spotlessCheck

Static Analysis

./gradlew detekt

Detekt reports are available at:

app/build/reports/detekt/detekt.html

Run All Checks

./gradlew check

This runs: - Spotless formatting check - Detekt static analysis - Unit tests

Build Configuration

Key build configuration files:

  • Project-level: build.gradle.kts
  • App-level: app/build.gradle.kts
  • Dependencies: gradle/libs.versions.toml
  • Properties: gradle.properties

Build Optimization

Enable Build Cache

The project uses Gradle build cache by default. To verify:

./gradlew build --build-cache

Parallel Execution

Gradle runs tasks in parallel by default. To control:

# gradle.properties
org.gradle.parallel=true
org.gradle.workers.max=4

Daemon Configuration

Gradle daemon improves build performance:

# gradle.properties
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m

Troubleshooting

Build Fails with Out of Memory

Increase heap size in gradle.properties:

org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=1024m

Slow Build Times

  1. Enable build cache
  2. Use Gradle daemon
  3. Increase worker count
  4. Use --no-daemon only when necessary

Dependency Resolution Issues

# Refresh dependencies
./gradlew --refresh-dependencies

# Clean and rebuild
./gradlew clean build

Next Steps