Facebook Audience Network with dfp mediation network

流过昼夜 提交于 2019-12-05 03:47:05

问题


App

It already uses dfp to get ads from admob as described in DFP Android Guides. Now I want to get ads from facebook audience network through dfp. I follow the guide here and add FacebookAdapter.jar and AudienceNetwork.jar into my app.

DFP

In my line item, I set type price priority and use sdk mediation ad with facebook audience network.

Condition

However, when the app runs, I see the following message just like someone else reported here.

W/FacebookAdapter(18649): The input ad size is not supported at this moment.

I think the code works, and dfp delivers the ads from facebook audience network. I am pretty sure about this because both dfp and facebook console show the ad request information.

Questions

  1. Do I setup the line item correctly?
  2. How could we fix the issue of unsupported ad size?

Update

  1. Nothing wrong about the line item setting. But if you use dfp for mediation, you need to be aware of the priority here
  2. Currently, the simplest solution is to give up smart banner and use banner instead. This would allow you to get mediation ad from facebook audience network.
  3. Don't forget to add -keep public class com.google.ads.mediation.** {*;} if you use proguard. Otherwise, you will see couldn't instantiate facebook adapter message.

回答1:


I use dfp sdk so if you use other sdk, I cannot guarantee it works. My code already works for admob and other mediation network, and I try to add facebook audience network.

layout.xml

<com.google.android.gms.ads.doubleclick.PublisherAdView
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:ads="http://schemas.android.com/apk/res-auto"
                android:id="@+id/adView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                ads:adSize="BANNER"
                ads:adUnitId="@string/ad_unit_id"
                android:visibility="gone" /> 

Note that I use BANNER instead of SMART_BANNER here, somehow, the banner size is incompatible between dfp and facebook. In my opinion, this is an issue of sdk. I hope google would fix this later, but I just give up SMART_BANNER for now. As I mentioned in the update, if you use SMART_BANNER, you will get this W/FacebookAdapter(18649): The input ad size is not supported at this moment.

jar

facebook android sdk - This one is from facebook, and you can find the AudienceNetwork.jar in it.

facebook adapter - This is from dfp mediation network, and you can find FacebookAdapter.jar.

In Android Studio, all you need to do is put jars in your libs folder and make sure your build.gradle includes the libs folder.

build.gradle

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
...
}

Somehow, when I build the apk, the libraries are not compiled even when I Synchronize 'build.gradle'. Hence, you might want to check your project.iml and make sure you see the following in it.

project.iml

...
    <orderEntry type="library" exported="" name="AudienceNetwork" level="project" />
    <orderEntry type="library" exported="" name="FacebookAdapter" level="project" />

Proguard

As I said in the reply, you must not forget to add com.google.ads.mediation if you use Proguard! Otherwise, you will keep seeing cannot instantiate com.google.ads.mediation.facebookadapter class.

-keep public class com.google.ads.mediation.** { public *; }

Log

This is the message you will see if everything is configured properly.

02-18 16:24:25.315 8081-8307/com.xxxxxxx I/Ads﹕ Trying mediation network: 1.0568273599589929E19 02-18 16:24:25.320 8081-8081/com.xxxxxxx I/Ads﹕ Instantiating mediation adapter: com.google.ads.mediation.facebook.FacebookAdapter 02-18 16:24:25.335 8081-8081/com.xxxxxxx W/Ads﹕ Server parameters: {"gwhirl_share_location":"1","pubid":"xxxxxxxxxxxxx_xxxxxxxxxxxxx"}

This is the simplest way to use Audience Network if you are willing to give up SMART BANNER. If you must use SMART BANNER, I suggest you to implement custom event banner using com.google.ads.mediation.customevent.CustomEventBanner yourself. In Vpon's Google Admob Mediation, it shows an example of implementation of custom evener banner. I think you will be able to use SMART_BANNER in this way, and it also means that you have to convert the ad size yourself.


Update

Targeting

I am actually not sure about if you can do targeting with facebook audience network or not because I cannot find anything about targeting in facebook's official document.

You can see dfp Custom targeting for this, and I guess the code would be something like .addNetworkExtrasBundle(new com.google.ads.mediation.facebook.FacebookAdapter(), bundle).

Placement id

In case you're not familiar with how to use placement_id you get from facebook audience network, you have to do the following things:

  1. Create a line order
  2. Create a line item
  3. Create a SDK mediation creative
  4. Select Facebook Audience Network like the image below and put your placement id there.

This is the very simple version of how you do it, and you should know that the setting of line item will have effects on ads. If you settings are not correct, for example, the item's type priority is too low or frequency capping is too long, you might not see the ads.


Feb 2016

You can use gradle to install audience network library now.

compile 'com.facebook.android:audience-network-sdk:4.+'

More information at Using the Native Ad API in Android

If you see the following messages without delivering any ad, that is probably because you don't have facebook app installed on your device or emulator.

E/ActivityThread: Failed to find provider info for com.facebook.katana.provider.AttributionIdProvider 
W/FacebookAdapter: No fill. We are not able to serve ads to this person. Please refer to https://developers.facebook.com/docs/audience-network/faq#a12. If you are integrating Audience Network for the first time, you can use test ads https://developers.facebook.com/docs/audience-network/testing.

May 2016

Yoann Hercouet points out in the comments that LARGE_BANNER is also not available on Facebook.




回答2:


there is a adsize matching issue inside the FacebookAdapter:

https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/android/MWoBWBR0FQM



来源:https://stackoverflow.com/questions/28430780/facebook-audience-network-with-dfp-mediation-network

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!