0

我将自定义 adUnitId 添加到我的 PublisherAdView 横幅广告,由发布者提供,以触发 Google 移动广告 SDK 调用我的自定义事件处理程序类,但我收到此错误消息:

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)

这是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() {
    
    }
}

在我的活动中,我已经像这样导入了MyCustomBannerAdapter:

import com.example.event.adapter.MyCustomBannerAdapter 

构建梯度

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

安卓清单

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

我正在关注官方的 Google 移动广告 SDK文档

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

知道如何触发调用 MyCustomBannerAdapter 吗?

4

1 回答 1

0

发现广告有一个后备数据,用于通过反射触发机制来调用 my MyCustomBannerAdapter.

于 2021-03-16T13:49:51.263 回答