OptiPessiProgrammer
OptiPessiProgrammer

Reputation: 2336

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.

Upvotes: 3

Views: 113

Answers (2)

user3677546
user3677546

Reputation:

Multiple APK names: The name of the MainActivity is used for the name of a APK. It is stated in the AndroidManifest.xml with the android:label tag and usually references the app_name String in the String.xml in the Folder values of your project. So simple change this String before exporting the second APK.

For your second approach: Why you don't change the String value itself if it is only one? In the case that there are more different take the use of multiple String Manifests and comment the other out. How to use multiple String.xml was already answered here.

Upvotes: 0

ben75
ben75

Reputation: 28706

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.

Upvotes: 1

Related Questions