Skip to content
Latchkey

gradlew: Android Build Tasks (assemble, bundle, test) in CI

The ./gradlew wrapper builds Android projects via tasks like assembleRelease (APK), bundleRelease (AAB), test (unit), and lint.

The Android Gradle Plugin exposes a task per build type and product flavor. Knowing that assemble* makes APKs, bundle* makes AABs, and connectedAndroidTest needs a device keeps CI pipelines predictable.

What it does

The Gradle wrapper (./gradlew) runs the pinned Gradle version and executes tasks the Android Gradle Plugin registers. assembleRelease produces a signed/unsigned APK, bundleRelease produces an .aab, test runs JVM unit tests, connectedAndroidTest runs instrumented tests on a device, and lint runs static analysis.

Common usage

Terminal
./gradlew assembleRelease
./gradlew bundleRelease
./gradlew test lint
./gradlew connectedDebugAndroidTest   # needs a booted emulator
./gradlew clean assembleDebug --stacktrace --no-daemon

Options

Task / flagWhat it does
assembleRelease / assembleDebugBuild the release / debug APK
bundleReleaseBuild the release Android App Bundle (.aab)
testRun local JVM unit tests
connectedAndroidTestRun instrumented tests on a connected device
lintRun Android Lint static analysis
--stacktrace / --infoVerbose failure output
--no-daemonDo not leave a Gradle daemon running (common in CI)

In CI

Run with --no-daemon on ephemeral runners so no daemon lingers, and raise the JVM heap in gradle.properties (org.gradle.jvmargs=-Xmx4g) to avoid OOM on large modules. Cache ~/.gradle/caches and the wrapper distribution keyed on the Gradle files. connectedAndroidTest requires a booted emulator first.

Common errors in CI

"./gradlew: Permission denied" means the wrapper lost its execute bit; run chmod +x ./gradlew or git update-index --chmod=+x gradlew. "Expiring Daemon because JVM heap space is exhausted" is a heap OOM; raise -Xmx. "SDK location not found. Define ANDROID_HOME" means the SDK path is unset. "License for package ... not accepted" means you skipped yes | sdkmanager --licenses.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →