Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SampleAdapter initialize() method never called in the sample #339

Open
eaullas opened this issue Jun 24, 2021 · 2 comments
Open

SampleAdapter initialize() method never called in the sample #339

eaullas opened this issue Jun 24, 2021 · 2 comments

Comments

@eaullas
Copy link

eaullas commented Jun 24, 2021

I was expecting the see the initialize() method of the SampleAdapter get called at application startup after adding the proper initialization code :

MobileAds.initialize(this, new OnInitializationCompleteListener() {
  @Override
  public void onInitializationComplete(InitializationStatus initializationStatus) {
      Map<String, AdapterStatus> statusMap = initializationStatus.getAdapterStatusMap();
      for (String adapterClass : statusMap.keySet()) {
        AdapterStatus status = statusMap.get(adapterClass);
        Log.d("MyApp", String.format(
              "Adapter name: %s, Description: %s, Latency: %d",
              adapterClass, status.getInitializationState(), status.getLatency()));
      }
      // Start loading ads here...
    }
});`

But the logging seems to indicate that the application is expecting to find a com.google.ads.mediation.sample.SampleMediationAdapter class instead of the com.google.ads.mediation.sample.adapter.SampleAdapter present in the sample:

D/MyApp: Adapter name: com.google.android.gms.ads.MobileAds, Description: READY, Latency: 44 D/MyApp: Adapter name: com.google.ads.mediation.mopub.MoPubMediationAdapter, Description: NOT_READY, Latency: 2 D/MyApp: Adapter name: com.google.ads.mediation.facebook.FacebookMediationAdapter, Description: NOT_READY, Latency: 4 D/MyApp: Adapter name: com.google.ads.mediation.applovin.AppLovinMediationAdapter, Description: NOT_READY, Latency: 2 D/MyApp: Adapter name: com.google.ads.mediation.sample.SampleMediationAdapter, Description: NOT_READY, Latency: 4 D/MyApp: Adapter name: com.google.ads.mediation.adcolony.AdColonyMediationAdapter, Description: NOT_READY, Latency: 12 D/MyApp: Adapter name: com.google.ads.mediation.inmobi.InMobiMediationAdapter, Description: NOT_READY, Latency: 3

@ericleich
Copy link
Member

@eaullas this is a bug in the sample. You've noticed that com.google.ads.mediation.sample.adapter.SampleAdapter is the adapter class and com.google.ads.mediation.sample.SampleMediationAdapter is the class that's expecting initialize. Due to the architecture evolving over time, naming of adapters being locked forever due to the reflective nature of them being called, but us modifying our adapter naming best practices over time, these class names can be different in some cases.

What we've done to get this working in production adapters (example) is to have the adapter class extend from the class that expects the init call.

@eaullas
Copy link
Author

eaullas commented Jun 25, 2021

Thanks @ericleich,
What I did on my side was rename the SampleAdapter to SampleMediationAdapter (+package move) to have its method initialize properly called.
Having done that, my real concern is where does the Adapter class name to be initialized come from ? From AdMob backend customEvent mediation source declaration ? Because I have my own Adapter class in my sample, which gets instantiated properly following the ad call to AdMob, but never got initialized in the first place (despite the MobileAds.initialize() call at application startup)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants