Android gradle command line list

This tutorials talks about gradle commands used in android application.

You can do the same tasks using android studio.

Knowing commands is helpful for mobile developers to get confidence on app build and deployment.

How to list tasks from command line in android application

gradle wrapper provides tasks command to list out all available tasks in Android app

In windows, Please run following command

gradlew tasks

In linux or mac or Unix flavours OS machines

gradlew tasks

How to build APK file in Android project?

Some times, We need to generate APK for debugging and testing app assembleDebug: Following is an command for generating debug APK file with default signed configuration.

gradlew assembleDebug

Output of the above command generates module-debug.apk in project/module/build/outputs/apk/ folder


It builds and generates release version of APK file

gradlew assembleRelease

It generates module-release.apk in project/module/build/outputs/apk/ folder assemble:

This generates debug and release version of apk for debug and release with default signing configuration

gradlew assemble

It generates module-release.apk and module-debug.apk in project/module/build/outputs/apk/ folder

How to install apk file to android devices?

install variants build and generates apk file and installs apk to available devices

gradlew installDebug // build & installs debug apk
gradlew install // build & installs release apk

How to deploy android app to emulator

  • First create an android virtual devices
  • Command line run below command to start emulator
android_sdk/tools/emulator -avd nameofavd
  • Next step is deploy to emulator with adb command
adb install  apkfilepath

apkfilepath is an apk file file generated with gradle assemble or gradle install command.

Normally, apk generates in project/module/build/outputs/apk/ folder by default.

How to build application bundle with Gradle?

Android application bundle contains compileed java code and required resources

Here is an command to generate bundled code

gradlew :base:bundleDebug
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
You'll get a notification every time a post gets published here.