5

I know there are a lot of questions out there about multiple Android versions pertaining to free/paid versions but this might be a little different.

My app currently uses AdMob for advertising and it's published on the Android Market and on the Samsung App Store. Unfortunately, the Samsung store will require everyone to migrate to their own Ad Network in the future, Samsung AdHub. Both AdMob and AdHub have their own libraries, their own SDKs.

I'm looking for a solution to build 2 different versions, one including AdMob the another including AdHub (and all the necessary code). What solutions do I have to easily build 2 versions without much hassle when it's time for a new version release?

Lots of solutions recommend to move the main project into a library project and then build 2 other apps which include the library project (the base project). But I'm not very fond of that solution (I prefer to keep my app in one single project, if possible) and I'm trying to look for alternatives and then make up my mind about which one is better for my needs.

rfgamaral
  • 16,546
  • 57
  • 163
  • 275
  • As a side request, can whoever answer this please also take into account the possibility of creating multiple apps from the same source ie "lite" and "premium" where the source code is the same but just a compile time switch activated. This does look like an ant question :-/ – Richard Green Jan 06 '12 at 15:37
  • If you do go the library route, you can just keep all your code and resources in the library and just have a different manifest file in the end projects. Then the code can check that for any different way it needs to behave. This prevents all the problems you can run into with bugs and just organization having spread out code, but still allows separate behavior apps to be built without having to tweak a constant every build. – Lance Nanek Oct 11 '12 at 18:37

4 Answers4

1

Some interesting solutions can be found here:

https://groups.google.com/d/topic/android-developers/8pRugcnzR_E/discussion

rfgamaral
  • 16,546
  • 57
  • 163
  • 275
1

The way to go now is to use Android Studio and use different Gradle flavors for each app. Thus, if you fix core functionality, you can quickly do a build for each appstore with it's own ad network.

Mulder
  • 154
  • 7
1

I'd think you should make this possible in your code using the Strategy design pattern. It suites well and can be switched at any trigger your like (even on runtime). If you make a facade for each jar file you will be able to change the dependencies while building, having the same source code.

Other option with this method is just making some configuration in your application that determines which library to use.

Jordi
  • 1,357
  • 12
  • 20
0

Library Projects is the way to go. Create a base project where you implement all the common stuff and then create two separate project that use the common one as a "Library". then just implement the rest needed to make the Apps behave differently.

Carlos Silva
  • 544
  • 3
  • 12
  • Or just import the two libraries and create a flag resource. When that flag is 1, pe, load the AdMob Ad, if it's 2, load the Samsung Ad. Simple... – Carlos Silva Jan 06 '12 at 16:18
  • Like I said, I don't like that solution. I'm looking for alternatives... If it's the only reasonable solution, I'll go with it. But first I need to have more options on the table so I can study the pros and cons of each one. – rfgamaral Jan 06 '12 at 17:29