Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio: Multiple APKs for Multiple Modules

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.

like image 867
RohanJ Avatar asked Mar 25 '15 12:03

RohanJ


1 Answers

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

like image 83
Asif Mujteba Avatar answered Sep 24 '22 01:09

Asif Mujteba