Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating multiple APKs with different source code

I use Jenkins to build my Android project, which currently just outputs one APK file.

I'd like to be able to output two APK files with, say, two different names (e.g., android-app-A.apk and android-app-B.apk).

In addition, I need a value in my source code to change between the A and B APK. In particular, its a String variable.

For example, for android-app-A, the String value should be foo. And for android-app-B, it should be bar. So if the app just displayed the String value, it would read foo when the person ran the android-app-A.apk and bar when the user ran android-app-B.apk

If it helps, I'm also using Maven to manage my Android project dependencies.

Is there any way to make this happen?

I've looked at Maven Profiles and skimmed a little of Android Developer's page on Maintaining Multiple APKs but I'm not sure what is the best approach and whether this is even possible.

like image 671
FilmiHero Avatar asked Apr 15 '26 07:04

FilmiHero


1 Answers

Maven is probably not the best build tool to achieve this. I strongly suggest you to use gradle as it contains a built-in feature : the productFlavor allowing you to do exactly what you need.

like image 173
ben75 Avatar answered Apr 16 '26 22:04

ben75