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
In linux or mac or Unix flavours OS machines
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.
Output of the above command generates
It builds and generates release version of APK file
project/module/build/outputs/apk/ folder assemble:
This generates debug and release version of apk for debug and release with default signing configuration
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