rfgamaral
rfgamaral

Reputation: 16842

How to implement multiple Android versions to use different libraries?

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.

Upvotes: 5

Views: 1147

Answers (4)

Mulder
Mulder

Reputation: 153

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.

Upvotes: 1

rfgamaral
rfgamaral

Reputation: 16842

Some interesting solutions can be found here:

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

Upvotes: 1

Carlos Silva
Carlos Silva

Reputation: 544

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.

Upvotes: 0

Jordi
Jordi

Reputation: 1367

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.

Upvotes: 1

Related Questions