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
./gradlew assembleRelease
./gradlew bundleRelease
./gradlew test lint
./gradlew connectedDebugAndroidTest # needs a booted emulator
./gradlew clean assembleDebug --stacktrace --no-daemonOptions
| Task / flag | What it does |
|---|---|
| assembleRelease / assembleDebug | Build the release / debug APK |
| bundleRelease | Build the release Android App Bundle (.aab) |
| test | Run local JVM unit tests |
| connectedAndroidTest | Run instrumented tests on a connected device |
| lint | Run Android Lint static analysis |
| --stacktrace / --info | Verbose failure output |
| --no-daemon | Do 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.