谷歌广告显示空白,你有什么建议?

时间:2014-01-13 18:58:48

标签: android admob adt ads banner

您好我能够添加google adMob横幅,它显示了元数据的错误消息,当我自己运行应用程序时,但是一旦我设法解决了这些问题,它就不会显示Google广告。它显示横幅,但它是空的。

我已将其设置为使得adView与背景的布局不同,并且显示何时点击屏幕。问题是,当您点击屏幕时,它会显示一个横幅较暗的区域,其中显示横幅错误(我假设它是GoogleAd横幅),但它显示为空。因此,只有它的区域变暗但没有显示任何内容。

这是我的MigratorisActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.migratoris_activity);

    final View controlsView = findViewById(R.id.fullscreen_content_controls);
    final View contentView = findViewById(R.id.GIFSingle);

    // Create the adView.
    adView = new AdView(this);
    adView.setAdUnitId("a--------------");
    adView.setAdSize(AdSize.BANNER);

    // Lookup your LinearLayout assuming it's been given
    // the attribute android:id="@+id/mainLayout".
    LinearLayout layout = (LinearLayout) findViewById(R.id.fullscreen_content_controls);

    // Add the adView to it.
    layout.addView(adView);

    // Initiate a generic request.
    AdRequest adRequest = new AdRequest.Builder().build();

    // Load the adView with the ad request.
    adView.loadAd(adRequest);

这是我的清单:

<uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data android:name="com.google.android.gms.version"
               android:value="@integer/google_play_services_version"/>
        <activity
            android:name="pt.quintas.migratoris.MigratorisActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name"
            android:theme="@style/FullscreenTheme" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.google.android.gms.ads.AdActivity"
             android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    </application>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>

任何人都知道为什么会显示但没有广告?可能是因为我将AdMob帐户设置为测试模式吗?

非常感谢你的时间, 佩德罗

这是布局

<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000000"
    android:id="@+id/MainLayout"
    tools:context=".MigratorisActivity" >

    <!--
         The primary full-screen view. This can be replaced with whatever view
         is needed to present your content, e.g. VideoView, SurfaceView,
         TextureView, etc.
    -->

    <pt.quintas.migratoris.GIFView
        android:layout_marginLeft="0dp" 
        android:layout_gravity="center"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:id="@+id/GIFSingle">
    </pt.quintas.migratoris.GIFView>

     <TextView
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="20dip"
        android:layout_gravity="center_horizontal|top"
        android:textStyle="bold"
        android:textSize="10pt"
        android:padding="16dip"

        android:textColor="#ffffffff"
        android:text="You have migrated for:" />

    <TextView
        android:id="@+id/textCounter"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="20dip"
        android:layout_gravity="center_horizontal|bottom"
        android:textStyle="bold"
        android:textSize="10pt"
        android:padding="16dip"

        android:textColor="#ffffffff"
        android:text="" />

    <!--
         This FrameLayout insets its children based on system windows using
         android:fitsSystemWindows.
    -->

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true" >

        <LinearLayout
            android:id="@+id/fullscreen_content_controls"
            style="?buttonBarStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center_horizontal"
            android:background="@color/black_overlay"
            android:orientation="horizontal"
            tools:ignore="UselessParent" >



        </LinearLayout>
    </FrameLayout>

</FrameLayout>

我试图在MainLayout中进行添加工作并且它有效我相信问题是用布局来膨胀,它需要更多空间。 这是logg:

01-15 16:50:53.552: I/ApplicationPackageManager(11135): cscCountry is not German : VOD
01-15 16:50:54.002: I/Ads(11135): Use AdRequest.Builder.addTestDevice("B246DEAA33A5FAE6AF9FF0A2F44B5CBC") to get test ads on this device.
01-15 16:50:54.002: I/Ads(11135): Starting ad request.
01-15 16:50:54.002: I/webclipboard(11135): clipservice: android.sec.clipboard.ClipboardExManager@4065d018
01-15 16:50:54.012: W/Ads(11135): Not enough space to show ad. Needs 480x75, but only has 474x754
01-15 16:50:54.022: W/Ads(11135): Not enough space to show ad. Needs 480x75, but only has 474x792
01-15 16:50:54.032: W/Ads(11135): Not enough space to show ad. Needs 480x75, but only has 474x792
01-15 16:50:54.052: E/GooglePlayServicesUtil(11135): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
01-15 16:50:54.182: E/GooglePlayServicesUtil(11135): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
01-15 16:50:54.223: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:54.273: E/GooglePlayServicesUtil(11135): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
01-15 16:50:54.443: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:54.663: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:54.893: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:55.183: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:55.384: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:55.584: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:55.804: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:56.134: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:56.224: I/Ads(11135): Ad finished loading.

3 个答案:

答案 0 :(得分:1)

您缺少XML文件中的com.google.ads.AdView,请尝试以下操作:

<com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="YOUR_ID"
        ads:refreshInterval="NUMBER_UP_TO_YOU" >
</com.google.ads.AdView>

如果这有助于您,请告诉我。

答案 1 :(得分:0)

我建议在xml布局文件中添加admob而不向src文件添加代码

    <com.google.ads.AdView
  android:id="@+id/adView"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  ads:adSize="BANNER"
  ads:adUnitId="YOUR_ID"
  ads:loadAdOnCreate="true"
  android:layout_alignParentBottom="true"
  ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />

并将其添加到布局文件的开头

 xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

下的

      xmlns:android="http://schemas.android.com/apk/res/android"

答案 2 :(得分:0)

尝试在真实设备中进行测试。您运行的模拟器可能没有Google Play服务

相关问题