Android Studio: Multiple APKs for Multiple Modules

荒凉一梦 提交于 2020-05-25 07:47:45

问题


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:


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



来源:https://stackoverflow.com/questions/29255618/android-studio-multiple-apks-for-multiple-modules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!