androidadmobfacebook-ads

What to replace FacebookAdapter&FacebookExtras with on com.google.ads.mediation:facebook:6.14.0.0?


Background

I had this on the project, to handle Facebook ads via Admob:

implementation 'com.google.ads.mediation:facebook:6.11.0.0'

And in code:

final AdRequest.Builder builder = new AdRequest.Builder();
builder.addNetworkExtrasBundle(FacebookAdapter.class, new FacebookExtras().setNativeBanner(true).build());
adLoader.loadAd(builder.build());

It works fine.

The problem

Now when updating to the new version (originally I asked about 6.12.0) :

implementation 'com.google.ads.mediation:facebook:6.14.0'

It shows that both FacebookAdapter and FacebookExtras don't exist anymore.

What I've tried

Checking on the docs, even though they say to use this version, the code they tell to use is the same as before:

Bundle extras = new FacebookExtras()
       .setNativeBanner(true)
       .build();

AdManagerAdRequest request =  new AdManagerAdRequest.Builder()
       .addNetworkExtrasBundle(FacebookAdapter.class, extras)
       .build();

EDIT: someone wrote that I should use this, but without any explanation of where he got this from, and I also failed to find the origin of it:

enter image description here

I tried to ask some questions about it, but then it got removed.

EDIT: It seems that the old instructions are now completely gone.

So perhaps it's not needed anymore:

https://developers.google.com/admob/android/mediation/meta#using_facebook_native_ads_without_a_mediaview

Then again, they still mention there the class that doesn't exist anymore : FacebookAdapter .

I tried to just update the dependency and remove the code that can't be used, but then I got this error while loading the native ad:

error code 3 - Unable to instantiate mediation adapter class.

The question

What should I use instead? How come it's not documented?


Solution

  • I think the documentation only added more information logs, and that now the minimal that we need is just to have the dependencies and that's it.

    If I'm wrong, please let me know.

    Sadly though, I still have the error, but I think the reason is something on the website/s (Facebook and/or Admob).

    EDIT: I think I had this missing in manifest, and as the project has it shared between 2 apps, one of them didn't have it:

            <meta-data
                android:name="com.google.android.gms.ads.APPLICATION_ID"
                android:value="@string/ad_mob_app_id" />
    

    Now I think it works fine.