1

I have generated an apk by following the below steps

Build->Generate signed apk->filling kestore values (i have created a keystore file by clicking create new,specified kestore path and the path where signed apk is to be generated)-> finish

Following These steps generated an apk named "app-release.apk" inside the specified folder. But no where the steps asked whether i need a paid version or a free version. So I am in doubt that am i following the right procedure?. Can anyone explain me about how to generate paid and free signed apks? Did i done the right thing for generating a free apk version?

Hari Krishnan
  • 5,992
  • 9
  • 37
  • 55
  • 1
    here's a link to get you [started](http://www.myandroidsolutions.com/2016/06/18/android-free-paid-versions-tutorial/) – Bill Jul 14 '16 at 17:58
  • Possible duplicate of [Common code for different android flavors](http://stackoverflow.com/questions/28563632/common-code-for-different-android-flavors) – R. Zagórski Jul 14 '16 at 18:00
  • so did i generated the free apk correctly? i haven't added any additional flavors in the app. – Hari Krishnan Jul 14 '16 at 18:12
  • It is not the process of generating the apk, but the settings on Google Play which differentiates between free and paid applications. It is another discussion that which feature(s) you want to remove from free version to get users into paid version. For this you need different set of codes which could be achieved through [productFlavors](http://www.pcsalt.com/android/product-flavors-android/) – Krrishnaaaa Jul 14 '16 at 18:27
  • so i did wrong in the above step? to generate a free apk version? – Hari Krishnan Jul 14 '16 at 19:38
  • When you generate an apk from Android Studio it isn't paid or free, it's just an apk. When you upload it to the Play Store(or other app store) you specify whether to charge users or not to download and install the apk. – Lewis McGeary Jul 14 '16 at 20:13
  • ok. so if i need my app to be completely free, then i can simply upload the apk that i have generated from the above steps to playstore by selecting a free version upload option there. ryt? – Hari Krishnan Jul 14 '16 at 20:20

1 Answers1

3

In some basic scenario you can do something like:

build.gradle:

productFlavors {
    free {
        buildConfigField("String","VERSION","free")
        applicationId "net.app.free" //package

    }
    paid {
        buildConfigField("String","VERSION","paid")
        applicationId "net.app.paid" //package
    }
}

Then in your code:

if(BuildConfig.VERSION.equals("paid"))
{
   //unlock paid feautre
}

To build all files at once run from console (in main app's directory), or open terminal window in IDE and type:

./gradlew build

All apks will be found in build directory.

So some basic information here after your comment:

There is no mandatory difference in building free or paid application. There is no mandatory difference in code. Both flavors need to be signed in this same way, published in this same way. You can set price when publishing app in google play and it has nothing to build process

piotrpo
  • 12,398
  • 7
  • 42
  • 58