Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 404
rfgamaral Avatar asked Oct 23 '22 13:10

rfgamaral


2 Answers

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.

like image 132
Jordi Avatar answered Nov 15 '22 05:11

Jordi


Some interesting solutions can be found here:

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

like image 41
rfgamaral Avatar answered Nov 15 '22 06:11

rfgamaral