Search code examples
androidandroid-gradle-pluginsigned-apk

Generating Signed APK from Android Source Code without Android Studio


I have bought an android app source code from codecanyon. I want to generate android apk for distribution without android studio. Any alternative?

Reason: I have some problem installing android studio in my pc which makes it impossible to use android studio.


Solution

  • You should specify signingConfigs and buildTypes in build.gradle's android block. For example:

    android {
        defaultConfig {
            ...
        }
        signingConfigs {
            config {
                keyAlias '...'
                keyPassword '...'
                storeFile file('../key.jks')
                storePassword '...'
            }
        }
        buildTypes {
            debug {
                useProguard false
                minifyEnabled false
                debuggable true
                applicationIdSuffix '.debug'
            }   
            release {
                signingConfig signingConfigs.config
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                useProguard true
                minifyEnabled true
                debuggable false
                shrinkResources true
            }
        }
    }
    

    Then from terminal or command prompt in root path of your project, run the following commands:

    // To generate debug apk
    gradlew assembleDebug
    
    // To generate release apk
    gradlew assembleRelease