【发布时间】:2017-04-21 21:38:16
【问题描述】:
我已将 AdMob(320x50 横幅)添加到我的项目中,并在调试模式下成功对其进行了测试。对于生产版本,我启用了 ProGuard 混淆并且横幅消失了。 我试过使用这些 ProGuard 规则,但不影响:
-keep public class com.google.android.gms.ads.** {
public *;
}
-keep public class com.google.ads.** {
public *;
}
我在我的 Application 类中初始化 AdMob,例如:
MobileAds.initialize(getApplicationContext(), getString(R.string.banner_ad_id));
在 xml 布局中我放置横幅:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
之后,我以这种方式加载横幅:
AdView adMobView = (AdView) bannerLayout.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adMobView.loadAd(adRequest);
另外,我正在使用第二个广告提供商 (adtech) 并根据条件调整其可见性。 知道如何让它们可见吗?
【问题讨论】:
-
您能否展示一下您是如何实施横幅广告的。
-
我不使用admob,但我注意到示例项目中的these settings。
标签: android firebase admob proguard