• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Newbie questions about flavors

exx1976

Lurker
I'm new to Android development, but not to programming.

I already have an app written and published in the play store.

What I would like to do is create a Lite version of this same app.

I want these to be two separate apps in the play store. The Lite version will have all the features of the full version, it will just be limited on how many entries users are allowed to make in the database (the goal is for them to try it out and see if they like it, then hopefully they decide to buy the full version).


I've been looking around online, and I *think* flavors are what I want. Is this right? Will flavors produce two separate APKs that I can upload to my developer console as different apps? Having trouble deciphering some of the finer points from some posts/videos I've found, figured asking some folks might be the best bet.


thanks!
 
I've not used flavors before, but it looks like it will do what you want. It allows the ability to have multiple 'source sets'. So you can have a different branch of code for each of your versions, each producing its own APK.
But I reckon this all could get a bit clunky and unmanageable, with multiple copies of source code flying around. It's not usually a good idea to duplicate your code, because it creates a maintenance problem when you have to change things in multiple places. But if you want to try flavors, then the Android dev website has some good info on it

https://developer.android.com/studio/build/build-variants.html

I personally would do this via a common code base, and get the app to detect which version of itself is running. Then it can decide what features to enable at runtime. In your case, if it's just a question of limiting the number of records allowed in the database, then going to the trouble of creating separate source sets for this seems overkill. I would just do this by looking at the app version, and it's very easy to control what goes into the database.
 
My understanding thus far with flavors is that you can "override" settings in the main app by using replacement code in the Lite flavor, but all the rest of the code from the main app will be inherited. This way I don't have two separate code bases for two different apps, just the one, with the "crippling" code in the Lite flavor.

My plan was to simply copy the DBHandler class and implement the cripple in there for the Lite version.

If this is not how you would do it, what would you recommend?

Can you give me an example of how I would do that?

I guess what I really don't understand is you say "a common code base" and then make run-time determinations. To me, if I want to publish these as separate apps, it sound like that would be two separate projects, one for each application. Wouldn't it? How would I get separate APKs? Or are you saying to upload the same APK to two different apps in the dev console?

Thanks for your help!
 
I don't know, I've never done it so maybe I'm not appreciating all the issues. You're probably ok with flavors then. I suppose the main thing you need, apart from being able to provide different sections of code, is the ability to produce distinct APKs for your various versions. Seems like that's what flavors is geared up to do.
 
Back
Top Bottom