Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build project without Android Studio

How to build Android Studio project using gradle without installing IDE, if i never installed gradle, but i have android sdk and jdk?

like image 446
Dima Avatar asked Jan 01 '26 09:01

Dima


2 Answers

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).

like image 140
Peter Niederwieser Avatar answered Jan 03 '26 23:01

Peter Niederwieser


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
like image 45
Piyush Agarwal Avatar answered Jan 03 '26 22:01

Piyush Agarwal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!