{

Android Gradle command line list


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 get confidence in app build and deployment.

How to list tasks from command line in android application

The Gradle wrapper provides a task’s command to list out all available tasks in the Android app.

In windows, Please run the following command

gradlew tasks

In Linux or Mac or Unix flavors OS machines.

gradlew tasks

How to build APK file in 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.

gradlew assembleDebug

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

assembleRelease:

It builds and generates a release version of the APK file.

gradlew assembleRelease

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

It generates debug and release versions of apk for debugging 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 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
  • 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 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

gradlew :base:bundleDebug
THE BEST NEWSLETTER ANYWHERE
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
Subscribe
You'll get a notification every time a post gets published here.