Android Studio: Multiple APKs for Multiple Modules
Asked Answered
P

1

6

In Android is there a way to generate signed APKs for all modules in a project. E.g. I have following project

Project
  -- Library Module
  -- Module 1
  -- Module 2
  -- Module 3

I want to generate APKs for all 3 modules in one command. Currently I have to separately use Generate Dialog for all 3 which takes a lot of time.

Plicate answered 25/3, 2015 at 12:25 Comment(0)
C
5

Yes you can generate multiple apk files with gradlew.

Open Terminal Window in Android Studio and run following commands:

1- Navigate to root folder of the project, where gradlew file is located

cd ..

2- Give executable permissions to gradlew (this needs to be done only once, no need to repeat again)

chmod a+x gradlew

3- Generate debuggable apks of all underlying modules.

./gradlew assembleDebug

You can also generate release apk files for all modules, by using this command instead

./gradlew assembleRelease

for more details, run the following command to see list of all tasks that can be run on gradlew

./gradlew tasks

Note: Running ./gradlew first time might result in terminal downloading the gradle files from server, wait for the downloading to complete before moving forward!

Hope that helps!

Update: For providing signing information in grade file, Open your module specific build.grade file and update it to contain this code:

signingConfigs {
    playstore {
        keyAlias 'KEY_ALIS_NAME_HERE'
        storeFile file('/PATH_TO_KEYSTORE_FILE_HERE/app.keystore')
        keyPassword 'KEY_PASSWORD_HERE'
        storePassword 'STORE_PASSWORD_HERE'
    }
}

buildTypes {
    release {
        minifyEnabled true
        proguardFiles 'proguard-file.txt'
        proguardFile 'proguard-file.txt'
        debuggable false
        signingConfig signingConfigs.playstore
    }
}

After that you can simply run ./gradlew assembleRelease to do the work :)

Celle answered 25/3, 2015 at 13:34 Comment(5)
Thanks this works. But it is generating unsigned APKs. Is there a way to generate signed APKs?Plicate
Modify your module specific build.gradle and specify signing configuration there for release.. and assembleRelease would automatically execute it!!Celle
Thanks a lot @Asif Mujteba. This is going to help me a lot.Plicate
@Asif Mujteba i am on windows and console gives me '.' is not recognized as an internal or external command", can you help?Fez
#60672917Conquian

© 2022 - 2024 — McMap. All rights reserved.