1

So I am making this app . I wanna have an app for free and a paid version too. I tried searching on google on how to implement it, but I couldnt find any proper threads. From some research I see In-app purchases is an option , but I'm not entirely clear. Can someone explain to me how this can be done? Thanks

R.Sriram
  • 41
  • 5
  • 1
    Possible duplicate of [Create Free/Paid versions of Application from same code](http://stackoverflow.com/questions/5590203/create-free-paid-versions-of-application-from-same-code) – OneCricketeer Nov 26 '16 at 16:21
  • Also see about product flavors. https://developer.android.com/studio/build/index.html – OneCricketeer Nov 26 '16 at 16:23

1 Answers1

5

You have to use flavors to achieve what you want. You need to have two different application id for each version. It will create *.apk with different id for free and paid version and therefore you will be able to upload two separate apps on Google Play.

android {

    productFlavors {           
        free {
            applicationId "com.myapp.free"
        }
        paid {
            applicationId "com.myapp.paid"
        }
    }   

}

Free version is build with:

gradlew assembleFreeRelease

Paid version is build with:

gradlew assemblePaidRelease

Your actual package can be different than application id:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.myapp">
</manifest>

In code you can check what flavor is used:

if (BuildConfig.FLAVOR.equals("free")) {
    //do sth only for free version   
}
Aleksander Mielczarek
  • 2,787
  • 1
  • 24
  • 43