To build an app on Android we may want to have different outputs based on specific Modifiable values, for example when implementing In-App Purchase for different markets (Google Play, Myket, etc.), with the Gradle tool for Android, this operation will be easy and there is no need to keep multiple sources for each application.
In this document, we'll explain the In-App Purchase for Google Play and Myket to get familiar with how this type of operation works.
First we need to change the geadle.build file:
- Add a variable:
- Add different flavors to the android element
In each flavor, we need to specify the value:
- Variable for use in-app codes
- Variable for use in the application manifest h file
- Specifying the value of the defined variable
Note that the value of the storePermission variable must be found in the Intended App Store In-App-Purchase Documentation. For example, this value is equal to "ir.mservices.market.BILLING" for Myket and "com.android.vending.BILLING" for Google play.
Application manifest file
Publish the app with a flavor
To select which of the ingredients to run, in the BuildVariants section of Android Studio, you can select different flavors and automatically change all the variables to the desired flavor.