Android AdMob Custom Adapter
Supported Ad Formats
- Banner
- Native: TradPlus only supports configuring self-rendering
- Interstitial
- Rewarded Video
SDK Versions
- AdMob SDK Version: v23.5.0
- TradPlus SDK Version: v12.9.0+
Google Backend Configuration
Prerequisites
Before configuration, ensure that you have already added the app to the Google AdMob backend and successfully created the ad unit.
Mediation Page
- Choose the Waterfall Sources tab and click Manage mappings in the current app.
- Select the ad unit ID and add the corresponding types for the custom platform.
- Example: Select Banner, click Add mapping to add parameters, then save it after completion.
- Mapping details:
- Mapping name:
TPMediation
(You can customize the name) - Class Name:
com.google.ads.mediation.customevent.AdNetworkCustomEvent
(Cannot be modified) - Parameter:
{ "appid": "The App ID you created on TradPlus", "pid": "The ad unit ID you configured on TradPlus" }
(Parameters from Google servers)
- Mapping name:
Mediation Groups
- Choose the Mediation groups tab and click Create mediation group.
- Select Ad format and Platform, then click Continue.
- Fill in the name (the "Mapping name" you provided earlier).
- Click on the Ad units tab, then click Add ad units and select the ad unit ID you created.
-
In Waterfall, click Add Custom event, fill in
TPMediation
in the Label, set the cost per thousand impressions (eCPM), and click Continue.- Testing Suggestion: During testing, set a high eCPM for
TPMediation
and a low eCPM for AdMob Network to prioritizeTPMediation
ads. After testing, adjust pricing to normal levels.
- Testing Suggestion: During testing, set a high eCPM for
SDK Integration
Dependency Libraries
Add the Maven Central repository in both the buildscript
and allprojects
sections of your project-level build.gradle
file:
buildscript {
repositories {
...
mavenCentral()
}
}
allprojects {
repositories {
...
mavenCentral()
}
}
Add Dependencies
Add the dependencies for TP SDK & TPMediation SDK to your module's app-level Gradle file:
// TradPlus
implementation 'com.tradplusad:tradplus:13.2.0.1'
//noinspection GradleCompatible
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.3.0-alpha02'
// TP Exchange
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.tradplusad:tp_exchange:40.13.2.0.1'
implementation(name: "customsdk_ads_1.0.0", ext: 'aar')
Download google_mediation_1.0.0.aar
Obfuscation Configuration
After enabling obfuscation, add the following rules to the proguard-rules.pro
file:
-keep public class com.tradplus.** { *; }
-keep class com.tradplus.ads.** { *; }
-keep class com.google.ads.mediation.customevent.** {*;}
Shrink Resources
Advertising SDK resources cannot be obfuscated. If using a third-party resource shrinking framework, exclude the SDK's resources by adding them to the whitelist:
R.string.tp_*
R.drawable.tp_*
R.layout.tp_*
R.id.tp_*
Advertising Initialization
AdMob supports automatically initializing other ad SDKs, so there is no need for separate initialization at the device level.
Ad Loading and Rendering
For ad requests and display instructions, refer to the official AdMob documentation: AdMob Banner Ads.
Testing and Verification
Testing should be conducted using TradPlus test mode: TradPlus SDK Test Mode
Supported test ad types:
Native Ads | Rewarded Video and Interstitial Ads | Banner Ads |
---|---|---|
![]() | ![]() | ![]() |