Skip to main content
This guide covers building Simple Alarm Clock using Gradle, including different build variants and configurations.

Build basics

Simple Alarm Clock uses Gradle as its build system. You can build the app using Android Studio or the command line.

Build using Android Studio

1

Open the project

Open the project in Android Studio if you haven’t already.
2

Select build variant

In the Build Variants panel (usually on the left side), select your desired build variant:
  • developDebug
  • developRelease
  • premiumDebug
  • premiumRelease
3

Build the app

Click Build > Make Project or use the keyboard shortcut Ctrl+F9 (Windows/Linux) or Cmd+F9 (Mac).
4

Run on device/emulator

Click the Run button or press Shift+F10 to build and run the app on a connected device or emulator.

Build using Gradle command line

All Gradle commands should be run from the project root directory:
# Make gradlew executable (Linux/Mac)
chmod +x gradlew

# Build debug APK
./gradlew assembleDevelopDebug

# Build release APK
./gradlew assembleDevelopRelease

# Build all variants
./gradlew assemble
On Windows, use gradlew.bat instead of ./gradlew.

Product flavors

The project has two product flavors with different application IDs:
productFlavors {
  create("develop") { 
    applicationId = "com.better.alarm" 
  }
}

Develop flavor

  • Application ID: com.better.alarm
  • Use case: Main development and F-Droid distribution
  • Available on: Google Play, F-Droid

Premium flavor

  • Application ID: com.premium.alarm
  • Use case: Premium version with additional features

Build types

The project defines two build types:

Debug

./gradlew assembleDevelopDebug
Features:
  • Application ID suffix: .debug (e.g., com.better.alarm.debug)
  • Code coverage enabled for both unit and instrumentation tests
  • Debuggable
  • No code obfuscation

Release

./gradlew assembleDevelopRelease
Features:
  • Signed with release keystore
  • ProGuard rules applied (minification currently disabled)
  • Optimized for distribution
Release builds require signing configuration. See the Signing configuration section below.

Build variants

With 2 flavors and 2 build types, you have 4 build variants:
VariantFlavorBuild TypeCommand
developDebugdevelopdebug./gradlew assembleDevelopDebug
developReleasedeveloprelease./gradlew assembleDevelopRelease
premiumDebugpremiumdebug./gradlew assemblePremiumDebug
premiumReleasepremiumrelease./gradlew assemblePremiumRelease

Signing configuration

Release builds require a signing configuration. The project expects the following environment variables:
export UPLOAD_KEYSTORE_PASSWORD=your_keystore_password
export UPLOAD_KEY_ALIAS=your_key_alias
export UPLOAD_KEY_PASSWORD=your_key_password
The keystore file should be located at app/upload-keystore.jks.
signingConfigs {
  create("release") {
    storeFile = file("upload-keystore.jks")
    storePassword = System.getenv("UPLOAD_KEYSTORE_PASSWORD")
    keyAlias = System.getenv("UPLOAD_KEY_ALIAS")
    keyPassword = System.getenv("UPLOAD_KEY_PASSWORD")
  }
}
Never commit your keystore file or credentials to version control!

Common Gradle tasks

Here are some commonly used Gradle tasks:
# Clean build artifacts
./gradlew clean

# Build debug APK
./gradlew assembleDevelopDebug

# Install debug APK on connected device
./gradlew installDevelopDebug

# Uninstall debug APK
./gradlew uninstallDevelopDebug

# Build and install
./gradlew installDevelopDebug

# List all available tasks
./gradlew tasks

# Check code formatting
./gradlew spotlessCheck

# Apply code formatting
./gradlew spotlessApply

Output locations

After building, APK files can be found in:
app/build/outputs/apk/
├── develop/
│   ├── debug/
│   │   └── app-develop-debug.apk
│   └── release/
│       └── app-develop-release.apk
└── premium/
    ├── debug/
    │   └── app-premium-debug.apk
    └── release/
        └── app-premium-release.apk

Continuous Integration

The project uses GitHub Actions for CI. The CI pipeline builds and tests the project on every push and pull request. CI build commands (from .travis.yml):
./gradlew assembleDevelopDebug
./gradlew testDevelopDebugUnitTest
To ensure your changes will pass CI, run these commands locally before pushing.

Troubleshooting

Build fails with “SDK location not found”

Create a local.properties file with your SDK path:
sdk.dir=/path/to/your/Android/sdk

Out of memory errors

Increase Gradle heap size in gradle.properties:
org.gradle.jvmargs=-Xmx2048M

Dependency resolution failures

Try cleaning and rebuilding:
./gradlew clean build --refresh-dependencies

Next steps

Build docs developers (and LLMs) love