I want to build an Android Studio app (the Gradle build system), but I want to do this via the command line.
You can execute all the build tasks available to your Android project using the Gradle wrapper command line tool. It's available as a batch file for Windows ( gradlew.
To run a Gradle command, open a command window on the project folder and enter the Gradle command. Gradle commands look like this: On Windows: gradlew <task1> <task2> … e.g. gradlew clean allTests.
Android Studio automatically creates a Gradle wrapper in the root of your project, which is how it invokes Gradle. The wrapper is basically a script that calls through to the actual Gradle binary and allows you to keep Gradle up to date, which makes using version control easier. To run a Gradle command, you can simply use the gradlew
script found in the root of your project (or gradlew.bat
on Windows) followed by the name of the task you want to run. For instance, to build a debug version of your Android application, you can run ./gradlew assembleDebug
from the root of your repository. In a default project setup, the resulting apk can then be found in app/build/outputs/apk/app-debug.apk
. On a *nix machine, you can also just run find . -name '*.apk'
to find it, if it's not there.
Try this (OS X only):
brew install homebrew/versions/gradle110
gradle build
You can use gradle tasks
to see all tasks available for the current project. No Android Studio
is needed here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With