0

I created two flavors for my app. A free and a pro version. The pro version has access to additional features(activities). I added the related res-folders for each flavor and updated my gradle:

 productFlavors {

        free {
            applicationId "com.***.***.free"
            versionName "1.0 - Beta - Free"
        }

        pro {
            applicationId "com.***.***.full"
            versionName "1.0 - Beta - Pro"
        }

    }

    sourceSets {

        free {
            res.srcDirs = ['src/free/res', 'src/free/res/']
        }

        pro {
            res.srcDirs = ['src/pro/res', 'src/pro/res/']
        }

    }

I added a button in the free version on the homescreen which should do the following:

  • open a dialog for the payment
  • if successful ... (do stuff)
  • start the pro - version

And at "..." are my questions: - When I move the additional pro-version activities and the related resources from the main-res-folder to the pro-res-folder, does the free version download not contain them, so they have to be downloaded when purchased? Or does the free-version download contain everything? So that I have to forbid the access to it from the free-version? Because it would be better if the free version only contains the necessary stuff and when you purchase the pro version the additional will be downloaded extra.

  • If not, how to do that?
XxGoliathusxX
  • 922
  • 13
  • 34

1 Answers1

0

Easy way
The usual and the easiest way to implement this flow is to create one app that includes all classes and resources and then programmatically disable some of them until in-app payment is done.


Possible way
It is possible not to include everything in apk:

  • Code (classes)
    You may load compiled code at runtime. Look at this and this. An issue is that activity classes must be registered in manifest, so they must exist in apk. Possible solution is to create these classes, but separate most of their logic to dynamically loaded code.
    Note that downloading executable code from a source other than Google Play is prohibited by Google Play's policy.

  • Resources
    Resources may be managed as files which are downloaded after successful in-app into app's directory. Then you may use them as files (not as resources, write more code to load them). In that way you'll need to handle orientation, language, etc., changes manually in your code. Also it seems to be impossible to use xml layouts, styles loaded in runtime, so you may left them in resources or replace them by programmatic setup (not to inflate resource, but construct layout in code).


More info

As for your config, free and pro flavors are different apps, because they have different package name (applicationId), so it is impossible to automatically migrate user from one to another.

Artyom
  • 1,165
  • 14
  • 22