Android SDK Connection🔗
Minimum requirements🔗
Minimum supported Android version is 4.4 (api 19).
Integration🔗
Step 1. Add the library to the project🔗
Add MRGS SDK, using your preferred method: via Maven or Manual install. And also do not forget to add services, depending on which store you plan to distribute your application through.
Gradle - Maven install🔗
- Add MRGS Maven repository in the root
build.gradle(forcom.android.tools.build:gradle:7.0.4and lower) or insettings.gradle(forcom.android.tools.build:gradle:7.1.0and higher) file of your project:
- Add next dependency in
build.gradlefile of your project:
Gradle - Manual install🔗
- Download the latest version of the library from the MRGS website. Unpack the archive.
- Copy a file called MRGService.aar from the archive into your project's directory with libraries (in most cases, libs).
- Add the libs directory to the flatDir section of the repository list in build.gradle:
Google Play Store - Add Services🔗
For Google Play Store you should add next dependencies:
dependencies {
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
implementation 'com.google.android.gms:play-services-appset:16.0.2'
}
Huawei/AppTouch Store - Add Services🔗
For Huawei/AppTouch Store, you should add next dependencies:
com.huawei.hms:ads-identifieraccording to documentation.com.huawei.hms:opendeviceaccording to documentation.
dependencies {
implementation 'com.huawei.hms:ads-identifier:3.4.62.300'
implementation 'com.huawei.hms:opendevice:6.11.0.300'
}
Step 2. Call the initialization method🔗
Call the initialization method MRGServices.service in the onCreate method of the Application class, or your main Activity. Need to pass some params: Context of your application, MRGS_APP_ID, and CLIENT_SECRET.
import games.my.mrgs.MRGSPlatform;
import games.my.mrgs.MRGService;
import games.my.mrgs.MRGServiceParams;
public class YourApplicationClass extends Application {
@Override
public void onCreate() {
super.onCreate();
final MRGServiceParams serviceParams = MRGServiceParams.init(<MRGS_APP_ID>, <CLIENT_SECRET>, MRGSPlatform.ANDROID);
serviceParams.setDebuggable(false);
MRGService.service(context, serviceParams);
}
}
MRGS_APP_ID and CLIENT_SECRET
MRGS_APP_ID - Application ID on the MRGS website. CLIENT_SECRET - Client Key. You can get them from the MRGS website, in the settings section of your application. 
Step 3 (Optional). Add account login tracking🔗
If your application uses a player identifier (USER_ID), it must be passed to MRGS using the method:
Step 4. Add payment tracking🔗
MRGS Billing
Payment tracking is necessary if you do not use the MRGSBilling module.
Upon validation of the payment, it is necessary to report data about it to MRGS.
Example for Amazon
productJson - product information in JSON format. You can get it by calling the com.amazon.device.iap.model.Product#toJSON() method.
receiptJson - purchase information in JSON format. You can get it by calling the com.amazon.device.iap.model.Receipt#toJSON() method.
userDataJson - buyer information in JSON format. You can get it by calling the com.amazon.device.iap.model.UserData#toJSON() method.
Example for Android
skuDetails - product information in JSON format. You can get it by calling the getSkuDetails method.
purchaseData - this is the INAPP_PURCHASE_DATA field received from Google reply after purchase getBuyIntent method.
dataSignature - this is the INAPP_PURCHASE_SIGNATURE field received from Google reply after purchase getBuyIntent method.
Example for Huawei/AppTouch
inAppPurchaseDataJson - purchase information in JSON format. You can get it by calling the com.huawei.hms.iap.entity.PurchaseResultInfo#getInAppPurchaseData() method.
inAppSignature - encrypted payment information. You can get it by calling the com.huawei.hms.iap.entity.PurchaseResultInfo#getInAppDataSignature() method.
Example for Samsung
productVoJson - product information in JSON format. You can get it by calling the com.samsung.android.sdk.iap.lib.vo.ProductVo#getJsonString() method.
purchaseVoJson - purchase information in JSON format. You can get it by calling the com.samsung.android.sdk.iap.lib.vo.PurchaseVo#getJsonString() method.
Example for third-party payment systems
Since MRGS 6.1.0 version, you can send payment information for any third-party payment systems to MRGS. Such payments will never be validated by MRGS, and they will be recorded in the database as is:
String transactionId = "1234-5678-000-ABCD";
String productId = "com.your.product.custom1";
float price = 10f;
String priceCurrency = "USD";
MRGSRevenue product = MRGSRevenue.newBuilder(transactionId, productId, price, priceCurrency)
.setTitle("Custom Product")
.setDescription("Custom product need for test")
.build();
MRGSPurchaseEvent customPurchaseEvent = MRGSPurchaseEvent.custom(product);
MRGSMetrics.addPurchase(customPurchaseEvent);
Integration check🔗
After completing the MRGS integration, we recommend that you verify that the library is working correctly. To learn how to perform this procedure, see Integration checks and troubleshooting section.
Created: 2020-01-20