How to create multiple APKs from one source project
I want to get multiple APKs from a single source project. It's just that the app name, icon and package name are different from others.
The project is on gradle (1.12) as shown below.
.
└── my_project
├── build.gradle
├── settings.gradle
└── module
├── build.gradle
└── src
How can i do this?
+3
source to share
2 answers
You can use productFlavors to do this, and under the ad and full folders (for example) create a strings file (promo / res / values / strings.xml) with the title of the update title, the same approach works 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 look like this
.
└── my_project
├── build.gradle
├── settings.gradle
└── module
├── build.gradle
└── src
├── main
├── promo
└── full
And to generate release apc apps just call next time (just make sure you add signature Configs and link it in your buildTypes versions)
gradle assembleRelease
+2
source to share
- All common files like java code, manifest and base resources are under "src / main"
- Move your specific application folders to "src / projects"
- declare two productFlavor (one for each application) with applicationId and versionName
- create two sourceSets (one for each project) pointing to specific res, java, etc. folders (i just needed res folder)
Complete project structure
Now use Build Options (bottom left of Android Studio) to select the app to launch
0
source to share