Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build multiple APKs from a single source project

Tags:

android

gradle

I wanna get multiple APKs from a single source project. Just the application's title, icon, and package name are different with the others.

The project is on gradle(1.12), as below.

.
└── my_project
    ├── build.gradle
    ├── settings.gradle
    └── module
        ├── build.gradle
        └── src

How can I do that?

like image 288
Woony Avatar asked Mar 20 '26 08:03

Woony


1 Answers

You can use productFlavors for that, and the under the promo and full folders (for example) create strings file (promo/res/values/strings.xml) with the update title value, same approach goes for the icon.

productFlavors {

    promo {
        packageName "com.woony.promo"
        versionCode 1
        versionName "v1.0.0_promo"
    }

    full {
        packageName "com.woony"
        versionCode 1
        versionName "v1.0.0"
    }

}

The updated project structure should be like the following

.
└── my_project
    ├── build.gradle
    ├── settings.gradle
    └── module
        ├── build.gradle
        └── src
            ├── main
            ├── promo
            └── full

And to generate the release apks just call the following once (just make sure you added signingConfigs and linked it in your release buildTypes)

gradle assembleRelease
like image 174
Mostafa Gazar Avatar answered Mar 21 '26 20:03

Mostafa Gazar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!