androidadaptermobile-ad-mediationgoogle-mobile-ads

Custom Event for Google Ads Mediation not calling yield partner defined class - CustomEventAdapter


Im adding an custom adUnitId to my PublisherAdView banner AD, provided by publishes in order to trigger Google Mobile Ads SDK to call my custom made event handler class, but instead i get this error message:

Ads: Could not load custom event implementation class: MyCustomBannerAdapter, assuming old implementation.
Ads: Could not instantiate mediation adapter: com.google.ads.mediation.customevent.CustomEventAdapter. 
java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object java.util.Map.get(java.lang.Object)' on a null object reference
        at com.google.android.gms.internal.ads.zzamo.zzdk(com.google.android.gms:play-services-ads-lite@@19.2.0:39)
        at com.google.android.gms.internal.ads.zzamo.zzdj(com.google.android.gms:play-services-ads-lite@@19.2.0:28)
        at com.google.android.gms.internal.ads.zzamo.zzdh(com.google.android.gms:play-services-ads-lite@@19.2.0:2)
        at com.google.android.gms.internal.ads.zzcix.zze(com.google.android.gms:play-services-ads@@19.2.0:31)
        at com.google.android.gms.internal.ads.zzcix.zzd(com.google.android.gms:play-services-ads@@19.2.0:14)
        at com.google.android.gms.internal.ads.zzcsv.zzf(com.google.android.gms:play-services-ads@@19.2.0:4)
        at com.google.android.gms.internal.ads.zzcve.zzb(com.google.android.gms:play-services-ads@@19.2.0:10)
        at com.google.android.gms.internal.ads.zzctz.zza(com.google.android.gms:play-services-ads@@19.2.0:34)
        at com.google.android.gms.internal.ads.zzcty.zzf(Unknown Source:10)
        at com.google.android.gms.internal.ads.zzdts.zza(com.google.android.gms:play-services-ads@@19.2.0:7)
        at com.google.android.gms.internal.ads.zzdtt.run(com.google.android.gms:play-services-ads@@19.2.0:41)
        at com.google.android.gms.internal.ads.zzdvj.run(com.google.android.gms:play-services-ads@@19.2.0:3)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)

This is MyCustomBannerAdapter:

public final class MyCustomBannerAdapter extends Adapter implements CustomEventBanner, CustomEventInterstitial {

    @Override
    public void initialize(Context context, InitializationCompleteCallback 
    initializationCompleteCallback, List<MediationConfiguration> list) {
    
    }

    @Override
    public VersionInfo getVersionInfo() {
        return null;
    }

    @Override
    public VersionInfo getSDKVersionInfo() {
        return null;
    }

    @Override
    public void requestBannerAd(Context context, CustomEventBannerListener customEventBannerListener, 
    String s, AdSize adSize, MediationAdRequest mediationAdRequest, Bundle bundle) {

    }

    @Override
    public void onDestroy() {
        
    }

    @Override
    public void onPause() {
        
    }

    @Override
    public void onResume() {
        
    }

    @Override
    public void requestInterstitialAd(Context context, CustomEventInterstitialListener 
    customEventInterstitialListener, String s, MediationAdRequest mediationAdRequest, Bundle bundle){
    
    }

    @Override
    public void showInterstitial() {
    
    }
}

And in my activity i have imported MyCustomBannerAdapter like this:

import com.example.event.adapter.MyCustomBannerAdapter 

Build gradle:

implementation 'com.google.android.gms:play-services-ads:19.0.0'

AndroidManifest:

<meta-data
    android:name="com.google.android.gms.ads.AD_MANAGER_APP"
    android:value="true" />

I was following official Gooogle Mobile Ads SDK documentation:

https://developers.google.com/ad-manager/mobile-ads-sdk/android/quick-start

Any idea how to trigger calling MyCustomBannerAdapter?


Solution

  • Found out that the Ad is having a fallback data, for triggering mechanism via reflection for calling my MyCustomBannerAdapter.