Question

I need some insight/suggestions/pointers (as detailed as possible) to implement a free and paid version of my android app. I use IntelliJ IDEA for development with SVN.

My aim is to maintain one code base which implements ads or paid features by simple booleans like "useAds" or "useFeatureX". Beyond that I think all that needs to happen is the package and app name are changed (?)

I've seen some older posts about converting the project to a library and other newer refs talking about Gradle flavors (I've never used Gradle). The former seems complex and I'm not quite sure from what I have read if it does what I am looking for. The latter sounds like it does but perhaps my unfamiliarity with Gradle makes it seem more daunting than it is.

Are there other ways? Is one of the above the way to go? What about security? I am using Proguard which I think strips out the unused code/classes from the final apk of the free version?

Thanks, sorry for the cluelessness.

Was it helpful?

Solution

Using gradle productFlavors is the easier way to achieve this. It will allow you to build the two editions from a single code base.

Regarding security, while Proguard would help you strip the unused classes from one of the editions, you can do it yourself with flavors, as you can actually provide separate code files per flavor if you need code to exist in one edition but not the other.

For the flags you want to use, you can very easily add them to your gradle build file by using buildConfigField.

You should check the official documentation. I've also written a simple tutorial showing how to use flavors to build multiple editions of the application.

I guess it's better to learn a bit about gradle and the android plugin first to build simple applications, then start diving into its extended features and configuration.

OTHER TIPS

thanks to new build system (NBS) based on gradle you can use flavors for that. i will give you a link to a tutorial. just use google to find more details

http://www.sajmons.com/news/gradlebuildwithfreeandpaidflavors

and here is full project on github

https://github.com/bmuschko/gradle-android-examples/tree/master/product-flavors

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top