Skip to main content
Version: v2.0

PremiumAds Google Adapter — Android Next-Gen

Dedicated adapter for publishers using Google's next-generation Mobile Ads SDK (com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk). This is a separate artifact from the legacy admob-adapter-v2 and is required when you're integrating the NextGen SDK.

Supported formats: Banner, Interstitial, Rewarded, Rewarded Interstitial, App Open, Native

Native ads require NextGen SDK 1.5.0+ and adapter 1.0.1+. On NextGen SDK 1.0.0 mediated native ads displayed but taps never opened the landing page, so native was disabled in adapter 1.0.0. Adapter 1.0.1 re-enables it on SDK 1.5.0 — see Native.

Prerequisites​

RequirementVersion
Google NextGen Mobile Ads SDK1.5.0+
Android minSdk24
Kotlin / JVM target17

If you're still on the classic play-services-ads SDK, use the standard PremiumAds Android adapter instead.

1. Add the Dependency​

settings.gradle.kts

dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url = uri("https://repo.premiumads.net/artifactory/mobile-ads-sdk/") }
}
}

app/build.gradle.kts

dependencies {
implementation("com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk:1.5.0")
implementation("net.premiumads.sdk:admob-adapter-nextgen:1.0.2")
}

Adapter 1.0.1+ depends on ads-mobile-sdk:1.5.0, so Gradle resolves the NextGen SDK to at least 1.5.0 even if your app declares an older version.

Staying on NextGen SDK 1.4.x​

If your app must stay on ads-mobile-sdk 1.4.x for now, pin it so Gradle does not upgrade it:

implementation("com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk") {
version { strictly("1.4.0") }
}
implementation("net.premiumads.sdk:admob-adapter-nextgen:1.0.2")

With this pin, Banner, Interstitial, Rewarded, Rewarded Interstitial and App Open work as on 1.5.0. Native ads do not: on SDK 1.4.x (and 1.0.x) a mediated native ad renders and counts impressions, but taps never open the landing page — the click bridge for mediated native ads only exists from SDK 1.5.0. Do not map native ad units to PremiumAds while pinned to 1.4.x. Our releases are verified on the SDK version the adapter declares (currently 1.5.0).

2. Configure the AdMob Custom Event​

In the AdMob console, add a Custom Event for each ad unit you want served via PremiumAds:

FieldValue
Class Namenet.premiumads.sdk.adapter.nextgen.PremiumAdsNextGenAdapter
ParameterYour PremiumAds ad unit ID (e.g. 1234567)

The same class name works for all supported formats — the adapter auto-detects the requested format from the mediation configuration.

3. Initialize the SDK​

Important: NextGen SDK requires initialization to run on a background thread.

import com.google.android.libraries.ads.mobile.sdk.MobileAds
import com.google.android.libraries.ads.mobile.sdk.initialization.InitializationConfig
import kotlin.concurrent.thread

class MyApp : Application() {
override fun onCreate() {
super.onCreate()
thread {
MobileAds.initialize(this, InitializationConfig.Builder().build())
}
}
}

4. Load Ads​

Use the standard NextGen SDK APIs — the mediation adapter is invoked automatically when AdMob routes a request to PremiumAds. No adapter-specific code is required.

import com.google.android.libraries.ads.mobile.sdk.banner.AdView
import com.google.android.libraries.ads.mobile.sdk.banner.AdSize
import com.google.android.libraries.ads.mobile.sdk.banner.BannerAd
import com.google.android.libraries.ads.mobile.sdk.banner.BannerAdRequest
import com.google.android.libraries.ads.mobile.sdk.common.AdLoadCallback

val adView = AdView(this).apply {
adSize = AdSize.BANNER
adUnitId = "ca-app-pub-xxxxx/xxxxx"
}
bannerContainer.addView(adView)
val request = BannerAdRequest.Builder(adView.adUnitId).build()
BannerAd.load(adView, request, object : AdLoadCallback<BannerAd> {
override fun onAdLoaded(ad: BannerAd) { /* shown automatically */ }
override fun onAdFailedToLoad(error: LoadAdError) { /* ... */ }
})

Interstitial​

import com.google.android.libraries.ads.mobile.sdk.interstitial.InterstitialAd
import com.google.android.libraries.ads.mobile.sdk.interstitial.InterstitialAdEventCallback

val request = AdRequest.Builder("ca-app-pub-xxxxx/xxxxx").build()
InterstitialAd.load(request, object : AdLoadCallback<InterstitialAd> {
override fun onAdLoaded(ad: InterstitialAd) {
ad.adEventCallback = object : InterstitialAdEventCallback {
override fun onAdShowedFullScreenContent() { /* ... */ }
override fun onAdDismissedFullScreenContent() { /* ... */ }
override fun onAdImpression() { /* ... */ }
override fun onAdClicked() { /* ... */ }
}
ad.show(activity)
}
override fun onAdFailedToLoad(error: LoadAdError) { /* ... */ }
})

Rewarded​

import com.google.android.libraries.ads.mobile.sdk.rewarded.RewardedAd
import com.google.android.libraries.ads.mobile.sdk.rewarded.OnUserEarnedRewardListener

val request = AdRequest.Builder("ca-app-pub-xxxxx/xxxxx").build()
RewardedAd.load(request, object : AdLoadCallback<RewardedAd> {
override fun onAdLoaded(ad: RewardedAd) {
ad.show(activity, OnUserEarnedRewardListener { reward ->
// reward.amount, reward.type
})
}
override fun onAdFailedToLoad(error: LoadAdError) { /* ... */ }
})

Rewarded Interstitial​

import com.google.android.libraries.ads.mobile.sdk.rewardedinterstitial.RewardedInterstitialAd

val request = AdRequest.Builder("ca-app-pub-xxxxx/xxxxx").build()
RewardedInterstitialAd.load(request, object : AdLoadCallback<RewardedInterstitialAd> {
override fun onAdLoaded(ad: RewardedInterstitialAd) {
ad.show(activity, OnUserEarnedRewardListener { reward -> /* ... */ })
}
override fun onAdFailedToLoad(error: LoadAdError) { /* ... */ }
})

App Open​

import com.google.android.libraries.ads.mobile.sdk.appopen.AppOpenAd

val request = AdRequest.Builder("ca-app-pub-xxxxx/xxxxx").build()
AppOpenAd.load(request, object : AdLoadCallback<AppOpenAd> {
override fun onAdLoaded(ad: AppOpenAd) {
ad.show(activity)
}
override fun onAdFailedToLoad(error: LoadAdError) { /* ... */ }
})

Native​

Render the ad in the NextGen NativeAdView and call registerNativeAd as usual. The adapter binds PremiumAds' native ad to your view, so impressions, clicks and the landing page are handled by the SDK — no adapter-specific code is needed.

import com.google.android.libraries.ads.mobile.sdk.nativead.NativeAd
import com.google.android.libraries.ads.mobile.sdk.nativead.NativeAdEventCallback
import com.google.android.libraries.ads.mobile.sdk.nativead.NativeAdLoader
import com.google.android.libraries.ads.mobile.sdk.nativead.NativeAdLoaderCallback
import com.google.android.libraries.ads.mobile.sdk.nativead.NativeAdRequest
import com.google.android.libraries.ads.mobile.sdk.nativead.NativeAdView

val request = NativeAdRequest.Builder(
"ca-app-pub-xxxxx/xxxxx",
listOf(NativeAd.NativeAdType.NATIVE)
).build()

NativeAdLoader.load(request, object : NativeAdLoaderCallback {
override fun onNativeAdLoaded(nativeAd: NativeAd) {
runOnUiThread {
val adView = layoutInflater.inflate(R.layout.native_ad, null) as NativeAdView
adView.headlineView = adView.findViewById<TextView>(R.id.ad_headline).apply { text = nativeAd.headline }
adView.bodyView = adView.findViewById<TextView>(R.id.ad_body).apply { text = nativeAd.body }
adView.callToActionView = adView.findViewById<Button>(R.id.ad_call_to_action).apply { text = nativeAd.callToAction }
adView.iconView = adView.findViewById<ImageView>(R.id.ad_icon).apply { setImageDrawable(nativeAd.icon?.drawable) }
val mediaView = adView.findViewById<MediaView>(R.id.ad_media)

nativeAd.adEventCallback = object : NativeAdEventCallback {
override fun onAdImpression() { /* ... */ }
override fun onAdClicked() { /* ... */ }
}
adView.registerNativeAd(nativeAd, mediaView)
nativeContainer.removeAllViews()
nativeContainer.addView(adView)
}
}
override fun onAdFailedToLoad(error: LoadAdError) { /* ... */ }
})

Image-only ads: nativeAd.mediaContent can be null for mediated image-only creatives. Keep a fallback ImageView and render nativeAd.image?.drawable into it when mediaContent is null.

5. Debug Logging​

Enable verbose adapter logging to trace loads, impressions, and clicks:

import net.premiumads.sdk.adapter.nextgen.PremiumAdsNextGenAdapter

PremiumAdsNextGenAdapter.setDebug(true)

Filter logs:

adb logcat -s PremiumAdsNextGenAdapter:V

Example output:

PremiumAdsNextGenAdapter: Debug mode enabled | PremiumAds Adapter v1.0.2
PremiumAdsNextGenAdapter: [Banner] Loading ad with unit: 1234567
PremiumAdsNextGenAdapter: [Banner] Ad loaded successfully
PremiumAdsNextGenAdapter: Cache HIT for adunit: 1234567
PremiumAdsNextGenAdapter: [Interstitial] Ad opened
PremiumAdsNextGenAdapter: [Interstitial] Impression recorded
PremiumAdsNextGenAdapter: [Interstitial] Ad closed
PremiumAdsNextGenAdapter: [Native] Ad loaded: headline='...'
PremiumAdsNextGenAdapter: [Native] rebound real ad to NativeAdView (mediaView=true)
PremiumAdsNextGenAdapter: [Native] NextGen onAdImpression → reportAdImpression
PremiumAdsNextGenAdapter: [Native] NextGen onAdClicked → reportAdClicked

6. GDPR / TCF v2.0​

IAB TCF v2.0 consent is read automatically from SharedPreferences by the adapter (standard AndroidX Preference storage). If you integrate Google's UMP SDK (or any TCF-compliant CMP), no additional adapter code is required.

ProGuard​

The adapter ships its own consumer ProGuard rules — no manual configuration needed.

Source & Releases​

Troubleshooting​

Adapter class not found in AdMob log: Verify the class name in the AdMob custom event is exactly net.premiumads.sdk.adapter.nextgen.PremiumAdsNextGenAdapter — note the .nextgen. package segment which distinguishes it from the legacy adapter class.

Ads never load:

  • Ensure MobileAds.initialize(...) has been called on a background thread before requesting an ad.
  • Double-check the PremiumAds ad unit ID set in the custom event parameter.
  • Enable debug logs (PremiumAdsNextGenAdapter.setDebug(true)) and filter adb logcat -s PremiumAdsNextGenAdapter:V for the load path.

Native ad shown but not clickable:

  • Check the adapter is 1.0.1+ and the resolved NextGen SDK is 1.5.0+ (./gradlew app:dependencies | grep ads-mobile-sdk). Adapter 1.0.0 returns a load error for native; on SDK < 1.5.0 taps don't reach the landing page.
  • Make sure the ad is rendered inside a NextGen NativeAdView (com.google.android.libraries.ads.mobile.sdk.nativead.NativeAdView) and that you call registerNativeAd(nativeAd, mediaView) after assigning the asset views.
  • With debug logging on, you should see rebound real ad to NativeAdView after the ad is displayed and onAdClicked → reportAdClicked on tap.

Documentation​

Support​

Contact your PremiumAds account manager or email [email protected].