I want to build an Android Studio app (the Gradle build system), but I want to do this via the command line.
Cheatsheet for running Gradle from the command line for Android Studio projects on Linux:
cd <project-root>
./gradlew
./gradlew tasks
./gradlew --help
Should get you started..
there are two build types to build your application using the Gradle build settings: one for debugging your application — debug — and one for building your final package for release — release mode.
First Navigate to Android studio project Root folder using CMD
run this command gradlew.bat assembleDebug
Edit the build.gradle file to build your project in release mode:
android {
...
defaultConfig { ... }
signingConfigs {
release {
storeFile file("myreleasekey.keystore")
storePassword "password"
keyAlias "MyReleaseKey"
keyPassword "password"
}
}
buildTypes {
release {
...
signingConfig signingConfigs.release
}
}}
Done.Good Luck!
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.
Official Documentation is here:
To build a debug APK, open a command line and navigate to the root of your project directory. To initiate a debug build, invoke the assembleDebug
task:
gradlew assembleDebug
This creates an APK named module_name-debug.apk
in project_name/module_name/build/outputs/apk/
.
enter code here
Create script file with below gradle and adb command, Execute script file
./gradlew clean
./gradlew assembleDebug ./gradlew installDebug
adb shell am start -n applicationID/full path of launcher activity
Only for MAC Users
Extending Vji's answer.
Step by step procedure:
Copy and paste this command and hit enter:
chmod +x gradlew
As Vji suggested:
./gradlew task-name
DON'T FORGOT TO ADD .(DOT) BEFORE /gradlew