Should I create a branch for the free version of my Android app?

I have an Android application that is a paid application and I would like to make a free version. The source code will be 95% the same for the free version. I use git for version control, and I started thinking about creating a free branch from master so that I can easily merge the changes from the paid version into the free one.

Is this the right strategy, given that some changes to the free branches will never be merged into master ?

Other options:

  • Creating another repo for the free version
  • Saving everything in master and creating library code, which is used in both free and paid versions
+4
source share
3 answers

I would rather keep the code together and use conditional compilations and / or โ€œpaidโ€ branch plugin libraries. The branch is supposed to be the deviation of the source tree during development. Branches should not be used to support separate codebases.

+2
source

You can create a paid wizard and a free wizard. Using the git flow method to manage your new features and bug fixes.

0
source

With the gradle build system, you can create different โ€œflavorsโ€ for your application.

android { ... defaultConfig { ... } signingConfigs { ... } buildTypes { ... } productFlavors { paid { applicationId "donturner.app.paid" versionName "1.0-paid" } free { applicationId "donturner.app.free" versionName "1.0-free" } } }

You can then create additional source folders for these assembly assemblies, which can be used to provide various implementations. For instance. app/src/free/java/ClassWithDifferences.java will provide a "free" implementation of app/src/paid/java/ClassWithDifferences.java .

Note: the code in app/src/main/ is shared between all tastes; therefore there should not be app/src/main/java/ClassWithDifferences.java . And be sure to use these flavors correctly, for example. a class that exists only in a free taste should not be mentioned in the main and should not be paid.

0
source

All Articles