它已使用dfp从admob获取广告,如DFP Android Guides中所述。现在我想通过dfp从facebook受众网络获取广告。我关注guide here并将FacebookAdapter.jar
和AudienceNetwork.jar
添加到我的应用中。
在我的订单项中,我设置了price priority
类型,并在Facebook受众群体网络中使用sdk mediation
广告。
但是,当应用运行时,我会看到以下消息,就像其他人报告here一样。
W/FacebookAdapter(18649): The input ad size is not supported at this moment.
我认为代码有效,dfp会从Facebook受众群体网络传播广告。我很确定这一点,因为dfp和facebook控制台都会显示广告请求信息。
-keep public class com.google.ads.mediation.** {*;}
。否则,您将看到无法实例化facebook适配器消息。答案 0 :(得分:6)
我使用dfp sdk所以如果你使用其他sdk,我不能保证它有效。我的代码已经适用于admob和其他中介网络,我尝试添加Facebook受众网络。
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" />
请注意,我在这里使用 BANNER 而不是 SMART_BANNER ,不知何故,横幅尺寸在dfp和facebook之间不兼容。在我看来,这是一个sdk的问题。我希望谷歌稍后会解决这个问题,但我现在就放弃了SMART_BANNER。正如我在更新中提到的,如果您使用SMART_BANNER,您将获得此W/FacebookAdapter(18649): The input ad size is not supported at this moment.
<强>罐
facebook android sdk - 这是来自Facebook,你可以在其中找到AudienceNetwork.jar
。
facebook adapter - 来自dfp mediation network,你可以找到FacebookAdapter.jar。
在Android Studio中,您只需将jar放在libs文件夹中,并确保build.gradle包含libs文件夹。
<强>的build.gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
...
}
不知何故,当我构建apk时,即使我Synchronize 'build.gradle'
,也不会编译库。因此,您可能需要检查project.iml并确保在其中看到以下内容。
<强> project.iml
...
<orderEntry type="library" exported="" name="AudienceNetwork" level="project" />
<orderEntry type="library" exported="" name="FacebookAdapter" level="project" />
<强> Proguard的
正如我在回复中所说,如果你使用Proguard,你不能忘记添加com.google.ads.mediation
!否则,您将看到不能instantiate com.google.ads.mediation.facebookadapter class
。
-keep public class com.google.ads.mediation.** { public *; }
<强>日志
如果一切配置正确,您将看到此消息。
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"}
如果您愿意放弃SMART BANNER,这是使用Audience Network的最简单方法。如果您必须使用SMART BANNER,我建议您使用com.google.ads.mediation.customevent.CustomEventBanner
实施自定义事件横幅你自己。在Vpon's Google Admob Mediation中,它显示了自定义evener横幅的实现示例。我认为您可以通过这种方式使用SMART_BANNER,这也意味着您必须自己转换广告尺寸。
定位
我实际上不确定您是否可以使用Facebook受众群体网络进行定位,因为我在facebook的官方文档中找不到任何关于定位的内容。
您可以看到dfp自定义定位,我猜测代码类似于.addNetworkExtrasBundle(new com.google.ads.mediation.facebook.FacebookAdapter(), bundle)
。
展示位置ID
如果您不熟悉如何使用placement_id,则可以从Facebook受众群体网络获取,您必须执行以下操作:
SDK mediation
广告
这是您如何操作的非常简单的版本,您应该知道订单项的设置会对广告产生影响。如果您的设置不正确,例如,商品的类型优先级太低或频次上限太长,您可能看不到广告。
您现在可以使用gradle安装受众群体网络库。
compile 'com.facebook.android:audience-network-sdk:4.+'
Using the Native Ad API in Android
的更多信息如果您在未投放任何广告的情况下看到以下消息,则可能是因为您的设备或模拟器上未安装Facebook应用。
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.
Yoann Hercouet在LARGE_BANNER is also not available on Facebook
的评论中指出。
答案 1 :(得分:0)
FacebookAdapter中存在广告匹配问题:
https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/android/MWoBWBR0FQM