| SDK Version | Date | Description |
|---|---|---|
| V1.2.0.2 | 2026-01-20 |
|
| V1.2.0.1 | 2026-01-07 |
|
| V1.2.0.0 | 2025-11-30 |
|
| V1.1.1.1 | 2025-10-16 |
|
Please add dependency in your App's build.gradle:
dependencies {
...
implementation 'ai.monetrix:monetrix-ads:1.2.0.2'
}
To improve ad performance, the SDK automatically adds the following declarations in the Manifest file:
This domain is intended to set up a local server, enabling video download while playing, which helps reduce ad loading time and improve impression rates. The specified domain whitelist does not violate any privacy policies, and the SDK strictly adheres to all applicable privacy regulations.
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
<application
...
android:networkSecurityConfig="@xml/network_security_config"
tools:replace="android:networkSecurityConfig"
...>
</application>
</manifest>
SDK automatically adds the following file:
res/xml/network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">127.0.0.1</domain>
</domain-config>
</network-security-config>
If a conflict with the
networkSecurityConfig
occurs after integrating the SDK, please resolve as follows.
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<application
...
android:networkSecurityConfig="@xml/network_security_config"
tools:replace="android:networkSecurityConfig"
...>
</application>
</manifest>
Refer to the sample code below: pass in the App ID and call
Monetrix.initialize()
to initialize SDK, and then use
Monetrix.InitListener
to monitor initialization results.
private void initSDK() {
InitConfig.Builder builder = new InitConfig.Builder()
.setAppId("App-ID");
InitConfig config = builder.build();
Monetrix.initialize(this.getApplicationContext(), config, new Monetrix.InitListener() {
@Override
public void onInitSuccess() {
log("SDK initialized");
}
@Override
public void onInitFail(int code, String message) {
log("SDK init failed: code=" + code + ",message=" + message);
}
});
}
Before requesting interstitial ads, please make sure the SDK has been initialized.
First, declare an
InstlAd
object, build an
InstlAdLoad
instance, and pass in the Placement ID. Then, create an
InstlAdLoader
instance, call the
loadAd()
method to request an ad, and use
AdLoadCallback
to receive callbacks from the ad request.
InstlAdLoad adRequest = new InstlAdLoad.Builder()
.withPlacementId(pid)
.build();
InstlAdLoader loader = new InstlAdLoader.Builder()
.withAdLoadCallback(new AdLoadCallback<InstlAd>() {
@Override
public void onError(@NonNull AdError error) {
log("onError " + error.getCode() + ";" + error.getMessage());
}
@Override
public void onAdLoaded(@NonNull InstlAd ad) {
handleAd(ad);
}
}).build();
loader.loadAd(adRequest);
After the ad is loaded (onAdLoaded), call
InstlAd.show()
to display, and register the ad events listeners with
InstlAd.setAdListener()
void handleAd(Ad ad) {
ad.setAdListener(new AdListener() {
@Override
public void onAdError(@NonNull AdError error) {
log("onAdError" + error);
}
@Override
public void onAdDisplayed() {
log("onAdDisplayed");
}
@Override
public void onAdClicked() {
log("onAdClicked");
}
@Override
public void onAdOpened() {
log("onAdOpened");
}
@Override
public void onAdClosed() {
log("onAdClosed");
}
});
((InstlAd) ad).show();
handleBid(ad);
}
Once the ad has been shown or is no longer used, destroy it using the following method:
ad.destroy();
Before requesting rewarded video ads, please make sure the SDK has been initialized.
First, declare a
RwdAd
object, build a
RwdAdLoad
instance, and pass in the Placement ID. Then, create a
RwdAdLoader
instance, call the
loadAd()
method to request an ad, and use
AdLoadCallback
to receive callbacks from the ad request.
private void loadRewardVideoAd(String pid) {
showProgress();
RwdAdLoader adLoader = new RwdAdLoader.Builder()
.withAdLoadCallback(new AdLoadCallback<RwdAd>() {
@Override
public void onError(@NonNull AdError error) {
log("onError " + error.getCode() + ";" + error.getMessage());
}
@Override
public void onAdLoaded(@NonNull RwdAd ad) {
handleAd(ad);
}
}).build();
RwdAdLoad adRequest = new RwdAdLoad.Builder()
.withPlacementId(pid)
.build();
adLoader.loadAd(adRequest);
}
After the ad is loaded (onAdLoaded), call
RwdAd.show()
to display, and register the ad events listeners with
RwdAd.setAdListener()
void handleAd(Ad ad) {
((RwdAd)ad).setAdListener(new RwdAdListener() {
@Override
public void onAdRewarded() {
log("onAdRewarded");
}
@Override
public void onAdError(@NonNull AdError error) {
log("onAdError" + error);
}
@Override
public void onAdDisplayed() {
log("onAdDisplayed");
}
@Override
public void onAdClicked() {
log("onAdClicked");
}
@Override
public void onAdOpened() {
log("onAdOpened");
}
@Override
public void onAdClosed() {
log("onAdClosed");
}
});
((RwdAd) ad).show();
handleBid(ad);
}
Once the ad has been shown or is no longer required, destroy it using the following method:
ad.destroy();
Before requesting banner ads, please make sure the SDK has been initialized.
First, declare a
BannerAd
object
BannerAd mBannerAd;
Then build a
BannerAdLoad
instance
BannerAdLoad adRequest = new BannerAdLoad.Builder()
.withPlacementId(pid)
.build();
Build a
BannerAdLoader
instance and pass in
AdLoadListener
to receive callbacks from the ad request, then call
loadAd()
to request an ad
BannerAdLoad adRequest = new BannerAdLoad.Builder()
.withPlacementId(pid)
.build();
BannerAdLoader loader = new BannerAdLoader.Builder()
.withAdLoadCallback(new AdLoadCallback<BannerAd>() {
@Override
public void onError(@NonNull AdError error) {
log("onError " + error.getCode() + ";" + error.getMessage());
}
@Override
public void onAdLoaded(@NonNull BannerAd ad) {
handleAd(ad);
}
}).build();
loader.loadAd(adRequest);
When a Banner Ad fills, use
BannerAd.adView()
method to fetch banner ad view and add it to your window
adViewContainer.addView(mBannerAd.adView());
Register ad events with
BannerAd.setAdListener()
method
void handleAd(Ad ad) {
ad.setAdListener(new AdListener() {
@Override
public void onAdError(@NonNull AdError error) {
log("onAdError" + error);
}
@Override
public void onAdDisplayed() {
log("onAdDisplayed");
}
@Override
public void onAdClicked() {
log("onAdClicked");
}
@Override
public void onAdOpened() {
log("onAdOpened");
}
@Override
public void onAdClosed() {
log("onAdClosed");
}
});
mAdContainerLayout.removeAllViews();
View view = ((BannerAd) mAd).adView();
if (view != null) {
mAdContainerLayout.addView(view);
}
handleBid(ad);
}
Once the ad has been shown or is no longer required, destroy it using the following method:
adViewContainer.removeAllViews(); mBannerAd.destroy();
Before initializing the SDK, please complete the following privacy configurations:
If no third-party CMP platform is integrated, you can use the following interface to pass whether the user has granted consent to share their personal information.
import com.monetrix.adsdk.Monetrix; Monetrix.setGDPRFlag(this, true); // user has granted consent to collecting and using personal info Monetrix.setGDPRFlag(this, false); // user refused to grant consent to collecting and using personal info
If the user is subject to the California Consumer Privacy Act (CCPA), you can use the following interface to pass whether the user has granted consent to share their personal information.
import com.monetrix.adsdk.Monetrix; Monetrix.setCCPAFlag(this, true); // user has granted consent to collecting and using personal info Monetrix.setCCPAFlag(this, false); // user refused to grant consent to collecting and using personal info
If your app is for children under 13, you must not use MonetriX SDK for monetization. If your app is for mixed-age users, you must use the following API to indicate whether the user is under the age of 13.
import com.monetrix.adsdk.Monetrix; Monetrix.setDirectToChildFlag(this, false); // The user is not a child under 13 Monetrix.setDirectToChildFlag(this, true); // The user is a child under 13
If you integrate Client Bidding, you can fetch the price for this impression and bid on client side
When ad fills, call the
getBid()
and
getBiddingPrice()
methods to obtain the price (unit: eCPM). Refer to the following example:
private void handleBid(Ad ad, boolean win) {
AdBid adBid = ad.getBid();
if (adBid != null) {
if (win) {
adBid.notifyWin("secondPrice", "secondBidder");// monetix wins
} else {
adBid.notifyLoss("winPrice","winBidder", "lossReason");// monetrix loses
}
log("thd biddingPrce for this ad is " + adBid.getBiddingPrice());
}
}
If MonetriX wins the bid, please call
notifyWin()
as shown below, and pass in the second-highest price and the name of the losing bidder.
void notifyWin(@Nullable Double secondPrice, @Nullable String secondBidder); //secondPrice (ecpm) //secondBidder bidder name of the losing bidder
If MonetriX loses the bid, please call
notifyLoss()
as shown below, and pass in the highest price, the winning bidder's name and the loss reason.
void notifyLoss(@Nullable Double winPrice, @Nullable String winBidder, @LossReason int lossReason); // winPrice (ecpm) // winBidder winning bidder's name // lossReason loss reason。1=unknow ; 100=price is lower than floor;102=price is lower than winning bidder
In order to validate sdk integration, you can use the following test ids. Test ids are 100% fill rate
Test App ID
:
10189633
Interstitial Test Placement ID
:
1100010010004
Rewarded Test Placement ID
:
1100010010005
| Code | Message |
|---|---|
| 1 | Load success |
| 700 | SDK initialization failed because of missing appid |
| 701 | SDK initialization failed because of no context passed |
| 702 | Load failed because sdk initialization failed or hasn't been initialized |
| 703 | Load failed because of coppa restriction |
| 704 | Load failed because of no pid passed |
| 705 | Load failed because the app is inactive, please check your app setup |
| 709 | load failed because the ad type and pid are inconsistent |
| 706~730 | No ad fill |