3

Can you release same APK file for free in India and Paid in some other countries?

If yes then how?

I have searched and found that we need to release two different apk's for similar situation.

INDRAJITH EKANAYAKE
  • 3,894
  • 11
  • 41
  • 63
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142

1 Answers1

2

There are many approaches you can take but I don't think you will be able to use the very same APK for both purposes due to the way Google Play store works. I believe in-app purchases are the closest you can get to distributing the same APK to different regions (free and paid). This means you will need to determine yourself when a user should pay for your app...and this is where the challenge is...knowing what country is your user coming from.

The approach I would follow involves creating 2 APKs with very little effort by creating two Product Flavours (Free, Paid). Again, using this approach you will end up with TWO APKs but to the best of my knowledge it is the most effective way to achieve your distribution goal.

The reason I believe this approach is more effective is because you don't need to add lots of evaluation in code to determine the device country. In fact, no matter what method you use to determine a device's (or user's) country, you will almost never be able to do much with that information. GPS location is not a good indicator (the user could be an Indian tourist in Spain or a Spanish tourist in India), telephony services will also fail for phones or tablets with no SIM cards. For that reason, I'll focus my answer on two product flavours and generating two APKs.

To create these two product flavours you'll need to declare them in gradle...

android {
    flavorDimensions "version"

    productFlavors {
        free {
            dimension "version"
            applicationIdSuffix ".free"
            versionNameSuffix "-free" 
        }

        paid {
            dimension "version"
            applicationIdSuffix ".paid"
            versionNameSuffix "-paid" 
        }
    }
}

The declaration above is simply telling Android Studio that the app is using two product flavours (Free and Paid) and that the applicationId (and version name) will be suffixed with the flavour name. This is necessary because you will be generating two APKs.

One thing to notice is that the all product flavours will "inherit" settings defined in the defaultConfig section, so you should define all common configurations in defaultConfig

Now, when you sync the project, Android Studio will create build variants based on these product flavours. Here's an example of one of my projects that DOESN'T use product flavours...

enter image description here

This is just using the common debug/release build types, but if I had configured the product flavours mentioned above you would see here 4 build variants:

  • freeDebug
  • freeRelease
  • paidDebug
  • paidRelease

Now, when you switch build variants you can provide different implementations of classes, different resources, etc. and most importantly, you will generate a different APK for each build variant when you build (or package) your app.

So, you will end up with a free release APK and a paid release APK that you can distribute spearately in Google Play. It might look like you have two different applications but the fact is that (development-wise) is almost the same application developed using Product Flavours and the effort to generate these two apps is minimum!!!

With all the above in mind, you can see that it's "quite easy" to:

  1. Add subscriptions or in-app purchases to only one flavour/variant (Paid)
  2. Distribute the free one to India
  3. Distribute the paid to the rest of the world

Now, I really don't know if there's an easy way to achieve the last point (3)...distributing in Google Play to all countries except one (India). It might be a daunting task having to select one country at a time

Leo
  • 14,625
  • 2
  • 37
  • 55
  • @AmitVaghela it's really hard to cover every single angle in this subject because the context is quite broad. But I updated my answer with more information about how you can take advantage of product flavours. It should give you a better understanding to get started – Leo Apr 18 '19 at 02:28
  • i was thinking, if one APK can serve both purpose will be a good thing to do and want make release with single APK. – Amit Vaghela Apr 18 '19 at 04:25
  • @AmitVaghela I don't know, it feels like a lot of effort to make it work and then there's the other issue...how or when to determine if the current installation is a free or paid one...? I would definitely use flavours which makes a lot of sense given the "limitations" in the framework and distribution platform – Leo Apr 18 '19 at 04:56