3

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.

FilmiHero
  • 2,306
  • 7
  • 31
  • 46

2 Answers2

1

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.

ben75
  • 29,217
  • 10
  • 88
  • 134
  • I can't use Gradle since my project and build environment is heavily dependant on Maven. – FilmiHero May 27 '14 at 20:02
  • I don't know what you mean by heavily... but you can use maven dependencies resolution with gradle and gradle integrates very well with jenkins – ben75 May 27 '14 at 20:12
0

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.

Community
  • 1
  • 1