Android Gradle command line list examples
This tutorial talks about gradle commands used in Android applications.
You can do the same tasks using Android Studio.
Knowing commands is helpful for mobile developers to gain confidence in app build and deployment.
How to list tasks from the command line in the Android application
Gradle wrapper provides a task command to list out all available tasks in the Android app.
In Windows, Please run the following command
In Linux or Mac or Unix flavors OS machines.
How to build an APK file in an Android project?
Sometimes, We need to generate APK for debugging and testing the app assembleDebug: Following is a command for generating debug APK files with default signed configuration.
The output of the above command generates
project/module/build/outputs/apk/ folder Another way is with offline mode.
./gradlew assembleDebug --offline
Generate apk files without downloading network dependencies. assembleRelease:
It builds and generates a release version of the APK file.
project/module/build/outputs/apk/ folder assemble:
It generates debug and release versions of apk for debugging and release with default signing configuration.
How to install apk files to Android devices?
install variants build and generate
apk file and install
apk to available devices
gradlew installDebug // build & installs debug apk
gradlew install // build & installs release apk
How to deploy the Android app to the emulator
- First, create Android virtual devices.
- Command-line run below command to start the emulator
android_sdk/tools/emulator -avd nameofavd
The next step is to deploy to the emulator with the ADB command
adb install apkfilepath
apkfilepath is an apk file generated with the
gradle assemble or
gradle install command.
Normally, apk generates in the project/module/build/outputs/apk/ folder by default.
How to build an application bundle with Gradle?
Android application bundle contains compiled Java code and required resources.
Here is a command to generate bundled code
Sync gradle scripts manually in Android studio
use the below command to syn without build
Below gradle version 5.1.1
With recent release
To run build and sync manually
How to check Dependencies for Updates in Android gradle
It checks the dependencies for updated versions and updates to it.
Check Gradle dependencies tries in a project
It displays the dependencies tree for an application.
For checking lint on the android project
For running unit tests of an Android project.
Check build process information using
For signing preoprt of a project.
Printing properties information using the below command