If the project was created with Android Studio, it should already have a gradlew
script in the root directory, which you can use to execute Gradle from the command line (e.g. gradlew build
).
Build project without Android Studio
-
04-10-2022 - |
Pregunta
How to build Android Studio project
using gradle
without installing IDE
, if i never installed gradle
, but i have android sdk
and jdk
?
Solución
Otros consejos
Steps to Build using Command line:
Open CMD and navigate it to project's root directory(You can also navigate to directory first using file Explore and then right click there keeping SHIFT key pressed and select Open Command window Here
from available option)
For Debug Builds Run the command :
gradlew assembleDebug
For Release Builds :
First you need to write the signing configuration inside your module's build.gradle file like
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 8
targetSdkVersion 14
}
signingConfigs {
mySigning{
storeFile file("YOUR_KEYSTORE_PATH")
storePassword "KEY_STORE_PASSWORD"
keyAlias "KEY_ALIAS"
keyPassword "ALIAS_PASSWORD"
}
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.mySigning
zipAlign true
}
}
}
After Configuration Run the command
gradlew assembleRelease
While executing the command it will automatically download required gradle version in you machine . If you want to change the gradle version you have to configure it in build.gradle file inside wrapper task if you have created
task wrapper(type: Wrapper) {
gradleVersion = '1.4' //1.4 is version
}
And if applicable you have to change distributionUrl
in gradle-wrapper.properties
file located at $ROOT_PROJECT_DIR/gradle like
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-bin.zip