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.

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks this works. But it is generating unsigned APKs. Is there a way to generate signed APKs?
Modify your module specific build.gradle and specify signing configuration there for release.. and assembleRelease would automatically execute it!!
Thanks a lot @Asif Mujteba. This is going to help me a lot.
@Asif Mujteba i am on windows and console gives me '.' is not recognized as an internal or external command", can you help?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.