【问题标题】:Admob ad not appearing in published app. Works fine in test modeAdmob 广告未出现在已发布的应用中。在测试模式下工作正常
【发布时间】:2014-09-03 01:42:52
【问题描述】:

[已解决] 我错误地为插页式广告而不是横幅广告提供了广告单元 ID。替换为正确的。现在一切正常。

我的应用中集成了一个 admob 广告单元。我可以在我的模拟器上看到测试广告。为了发布应用程序,我从代码中删除了 .addTestDevice。该应用程序已发布并可在 Google Play 上使用。但是在设备上,admob 广告没有出现。它显示空白区域。我已经为 admob 中的广告单元配置了自家广告。甚至房屋广告也没有显示。在 admob 帐户报告中,我看到近 1000 个请求但印象数为零。该应用是在一周前发布的,我已经验证了我的广告单元 ID。

我正在使用以下代码

1) 在我的 onCreate 活动中

 AdRequest adRequest = new AdRequest.Builder()
   //      .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
   //      .addTestDevice("B3EEABB8EE11C2Bxxxxxxxxxxxxxxxx")
         .build();
 adView.loadAd(adRequest);

2) 布局文件

<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/res-auto"

    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">



    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:baselineAligned="false"
            android:orientation="vertical" >

        <!-- As the main content view, the view below consumes the entire
              space available using match_parent in both dimensions. -->
        <com.google.android.gms.ads.AdView android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ads:adUnitId="ca-app-pub-80501638xxxxxxxx/xxxxxxxxxx"
            ads:adSize="BANNER"/>

        <WebView
            android:id="@+id/activity_main_webview"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
        </LinearLayout>
    </FrameLayout>

    <!-- android:layout_gravity="start" tells DrawerLayout to treat
         this as a sliding drawer on the left side for left-to-right
         languages and on the right side for right-to-left languages.
         If you're not building against API 17 or higher, use
         android:layout_gravity="left" instead. -->
    <!-- The drawer is given a fixed width in dp and extends the full height of
         the container. -->
    <fragment android:id="@+id/navigation_drawer"
        android:layout_width="@dimen/navigation_drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:name="com.staffcorner.staffcorner.app.NavigationDrawerFragment"
        tools:layout="@layout/fragment_navigation_drawer" />

</android.support.v4.widget.DrawerLayout>

请求您帮助解决问题

Logcat 的日志(通过过滤器 I/Ads 获得)07-15 20:14:25.727

3483-3483/? I/Ads:开始广告请求。 07-15 20:14:25.735
3483-3483/? I/Ads﹕使用 AdRequest.Builder.addTestDevice("CEE7456B4FC811C99B9CC0xxxxxxxxxx") 到 在此设备上获取测试广告。 07-15 20:14:25.760 3483-3483/?我/广告﹕ 请将 AdActivity 的主题设置为 @android:style/Theme.Translucent 为 启用透明背景插页式广告。 07-15 20:14:26.800 24037-24037/? I/Ads:JS:文档是从应用程序缓存中加载的 有清单 https : //googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.appcache (https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html:0) 07-15 20:14:26.800 24037-24037/? I/Ads﹕JS: 应用程序缓存 检查事件 (https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html:0) 07-15 20:14:28.858 24037-24037/? I/Ads﹕JS: 应用程序缓存 无更新事件 (https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html:0) 07-15 20:14:28.891 3483-3623/? I/Ads﹕没有来自广告服务器的填充。

这是应用在 admob 测试模式下的日志

07-15 20:52:41.054 13884-13884/com.staffcorner.staffcorner.app I/Ads﹕ 开始广告请求。 07-15 20:52:41.071 13884-13884/com.staffcorner.staffcorner.app I/Ads﹕请设定主题 AdActivity 为@android:style/Theme.Translucent 启用透明 背景插页式广告。 07-15 20:52:41.205 13884-13945/com.staffcorner.staffcorner.app D/dalvikvm﹕DEX prep '/data/data/com.staffcorner.staffcorner.app/cache/ads217249737.jar': 0ms 解压,重写 130ms 07-15 20:52:41.916 24037-24037/?我/广告﹕ JS:文档是从带有清单的应用程序缓存中加载的 https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.appcache (https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html:0) 07-15 20:52:41.917 24037-24037/? I/Ads﹕JS: 应用程序缓存 检查事件 (https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html:0) 07-15 20:52:42.341 24037-24037/? I/Ads﹕JS: 应用程序缓存 无更新事件 (https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html:0) 07-15 20:52:44.711 13884-13884/com.staffcorner.staffcorner.app I/Ads﹕ 从现在开始安排广告刷新 60000 毫秒。 07-15 20:52:44.718 13884-13884/com.staffcorner.staffcorner.app I/Ads﹕广告完成 正在加载。

【问题讨论】:

  • 日志是怎么说的?
  • 我只能使用 AdRequest.Builder.addTestDevice("CEE7456B4FC811C99B9CC0xxxxxxxxxx") 在此设备上获取测试广告。
  • Admob 生成的日志要多得多。将所有内容添加到您的问题中。
  • 谢谢威廉先生。我尝试了错误的过滤器来过滤日志。请找到日志,我在问题的末尾添加了

标签: android android-studio admob


【解决方案1】:

没有广告展示的原因是没有广告填充。见

 07-15 20:14:28.891 3483-3623/? I/Ads﹕ No fill from ad server.

【讨论】:

  • 我没有在 logcat 中出现这样的东西,但是如果我从测试模式中删除了广告,则无法看到广告。
  • 请告诉我还有什么要更新的。
  • @iDroidExplorer 如果您请求了广告,那么您的日志将包含广告请求和广告结果信息。如果这不能帮助您根据您的具体情况提出一个新问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-22
  • 1970-01-01
相关资源
最近更新 更多