广告横幅不显示

时间:2015-09-26 09:28:58

标签: java android admob logcat

当我在模拟器中测试我的项目时,非页内广告的工作正常,但Logcat上的横幅广告出现了错误

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="3dp"
    android:background="@drawable/backgroundblankyellow"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/LinearFailed"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:orientation="vertical"
        android:visibility="gone" >

        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:scaleType="fitXY"
            android:src="@drawable/imageheadbackblack" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:background="@drawable/backgroundfailed"
            android:gravity="center"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginBottom="50dp"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:layout_marginTop="50dp"
                android:background="@drawable/imagepopup"
                android:gravity="center"
                android:orientation="vertical" >

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginBottom="10dp"
                    android:layout_marginTop="10dp"
                    android:gravity="center"
                    android:orientation="horizontal" >

                    <ImageView
                        android:id="@+id/imagenewbesttap"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:scaleType="fitCenter"
                        android:src="@drawable/imageplaynewhighscore"
                        android:visibility="gone" />

                    <TextView
                        android:id="@+id/textbesttap"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="BEST TAP"
                        android:textSize="20sp"
                        android:textStyle="italic|bold"
                        android:typeface="serif"
                        android:visibility="visible" />

                    <TextView
                        android:id="@+id/besttap"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_gravity="center"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textSize="50sp"
                        android:textStyle="bold|italic"
                        android:typeface="serif" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginBottom="10dp"
                    android:layout_marginTop="10dp"
                    android:orientation="horizontal" >

                    <TextView
                        android:id="@+id/texttapped"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_gravity="center"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="CURRENT"
                        android:textSize="20sp"
                        android:textStyle="italic|bold"
                        android:typeface="serif" />

                    <TextView
                        android:id="@+id/currenttap"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_gravity="center"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textSize="50sp"
                        android:textStyle="bold|italic"
                        android:typeface="serif" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:background="@drawable/imageunder"
                    android:gravity="center" >

                    <Button
                        android:id="@+id/buttonrestart"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_margin="25dp"
                        android:layout_weight="1"
                        android:background="@drawable/buttonrestart" />

                    <Button
                        android:id="@+id/buttonmenu"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_margin="25dp"
                        android:layout_weight="1"
                        android:background="@drawable/buttonmenu" />

                </LinearLayout>
            </LinearLayout>
        </LinearLayout>

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:scaleType="fitXY"
            android:src="@drawable/imageheadbackblack" />

    </LinearLayout>

    <FrameLayout
        android:id="@+id/FrameLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@drawable/imageheadbackblack"
        android:visibility="gone" >

        <Chronometer
            android:id="@+id/chronometer1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right|center"
            android:textStyle="bold|italic"
            android:typeface="serif"
            android:visibility="invisible" />

        <TextView
            android:id="@+id/totaltap"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left|center"
            android:layout_marginLeft="10dp"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textSize="16sp"
            android:textStyle="italic"
            android:typeface="serif"
            android:visibility="invisible" />

        <TextView
            android:id="@+id/besttotaltap"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginRight="10dp"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textStyle="bold"
            android:typeface="serif"
            android:visibility="invisible" />
    </FrameLayout>

    <ImageView
        android:id="@+id/rulesimage"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:scaleType="fitXY"
        android:src="@drawable/playimage"
        android:visibility="visible" />

    <LinearLayout
        android:id="@+id/playlinear"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="2dp"
        android:layout_weight="1"
        android:background="@drawable/backgroundplay"
        android:orientation="vertical"
        android:visibility="gone" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1" >

            <Button
                android:id="@+id/yellow16"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />

            <Button
                android:id="@+id/yellow15"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />

            <Button
                android:id="@+id/yellow14"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />

            <Button
                android:id="@+id/yellow13"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1" >

            <Button
                android:id="@+id/yellow12"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />

            <Button
                android:id="@+id/yellow11"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />

            <Button
                android:id="@+id/yellow10"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />

            <Button
                android:id="@+id/yellow9"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1" >

            <Button
                android:id="@+id/yellow8"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />

            <Button
                android:id="@+id/yellow7"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />

            <Button
                android:id="@+id/yellow6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />

            <Button
                android:id="@+id/yellow5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1" >

            <Button
                android:id="@+id/yellow4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />

            <Button
                android:id="@+id/yellow3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />

            <Button
                android:id="@+id/yellow2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />

            <Button
                android:id="@+id/yellow1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/buttonyellowflash"
                android:visibility="invisible" />
        </LinearLayout>
    </LinearLayout>

    <FrameLayout
        android:id="@+id/FrameLayout2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:background="@drawable/imageheadbackblack"
        android:visibility="gone" >

        <TextView
            android:id="@+id/countdowntext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textStyle="bold|italic"
            android:typeface="serif"
            android:visibility="invisible" />
    </FrameLayout>

     <com.google.android.gms.ads.AdView
         android:id="@+id/adView"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center"
         ads:adSize="BANNER"
         ads:adUnitId="@string/banner_ad_unit_id" />

</LinearLayout>

这是我的xml数据

new

任何人都可以帮我解决这个问题吗?如何解决导致广告无法显示的错误?

提前感谢

1 个答案:

答案 0 :(得分:1)

log-cat中的错误属于xml文件中的BANNER广告,即com.google.android.gms.ads.AdView。它与插页式广告无关。

发生错误是因为在您的布局中,广告没有足够的空间加载。请参阅错误logcat

中的以下消息
  

没有足够的空间来展示广告。需要320x50 dp,但只有313x526 dp。

重新设计您的布局,并确保com.google.android.gms.ads.AdView有足够的高度来加载内容。

相关问题