AdMob的广告没有显示出来广告、AdMob

2023-09-08 18:49:29 作者:献给爱丽丝

我有与Admob的一个问题,没有显示广告......

I've got a problem with Admob not showing up Ads...

这里的LogCat中:

Here's the LogCat:

WARN/AdMobSDK(502): Ignoring requestFreshAd() because we are requesting an ad right now already.
INFO/AdMobSDK(502): No fill.  Server replied that no ads are available (1164ms)
INFO/AdMobSDK(502): No fill.  Server replied that no ads are available (846ms)

我已经试过测试模式,没有测试模式,仿真器,真正的手机,等等。它从来没有显示任何东西,但我得到Admob的统计数据一样,如果它曾经工作过的请求,并打印。 ..

I've tried test mode, no test mode, emulator, real phone, etc. It never shows anything up, but I get requests and prints on Admob stats, like if it ever worked...

AFAIK,我所做的一切都在Admob的Andr​​oid SDK中......这可能是什么问题,恕我直言,事业的唯一的事情,是我使用与滚动型标签布局,然后一个RelativeLayout的该广告的事实显示...

AFAIK, I did everything in the Admob Android SDK... the only thing that could be the cause of any problems, IMHO, would be the fact that I'm using tabbed layout with scrollview and then a relativelayout where the ad shows...

下面是一个标签布局的一个示例:

Here's a sample of the layout for a tab:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:myapp="http://schemas.android.com/apk/res/com.xxx.xxx"
    android:id="@+id/tababout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FF000000">
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FF000000"
    android:padding="10px">

    <ImageView
        android:id="@+id/label_img"
        android:src="@drawable/about_header"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:scaleType="centerInside" />

    <TextView android:id="@+id/label_know_more_desc"
        style="@style/Desc"
        android:layout_below="@id/label_img"
        android:text="@string/tab_about_know_more_desc" />

    <Button android:id="@+id/bt_know_more"
        style="@style/Button"
        android:gravity="center_vertical|center_horizontal"
        android:layout_below="@id/label_know_more_desc"
        android:text="@string/tab_about_know_more_bt" />

    <com.admob.android.ads.AdView android:id="@+id/ad" android:layout_width="fill_parent" android:layout_height="wrap_content" myapp:backgroundColor="#000000" myapp:primaryTextColor="#FFFFFF" myapp:secondaryTextColor="#CCCCCC" />
</RelativeLayout>
</ScrollView>

和这里的main.xml中,并不是说我认为你需要它:

And here's the main.xml, not that I think you need it:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF000000">

<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#FF000000"
        android:paddingTop="5px">

    </FrameLayout>
</LinearLayout>
</TabHost>

我读Admob广告不显示的时候放在里面TabView的的,这个问题可能是10px的填充,我扔了,但即使我禁用,这是行不通的。

I've read in Admob ads will not display when placed inside a tabview that the problem could be the 10px padding I'm throwing in, but even if I disable that, it doesn't work.

我甚至尝试移动的xmlns:MyApp的,以RelativeLayout的,但显然并没有改变什么......

I even tried moving the xmlns:myapp to RelativeLayout, but obviously didn't change anything....

另外,我做了我的第一个活广告请求超过24个小时前...

Also, I've made my first live ad request over 24 hours ago...

修改

好了,现在我得到的地方,我已经成功地得到测试广告显示出来(我setTestDevices是在OnCreate code为时已晚,我将它推到第一线),而不是以假乱真......我失去了一些东西?我明明注释掉setTestDevices线,没有广告现身

Ok, now I'm getting somewhere, I've managed to get test ads showing up (my setTestDevices was too late in the onCreate code, I pushed it up to the first lines), but not real ones... am I missing something? I obviously commented out the setTestDevices line and no ads show up

编辑2

嗯,我加了两个内置广告(我已经有内部广告启用,但内部没有广告设置),突然的广告开始出现在我的应用程序(不只是内部的广告)。

Well, I added two internal ads (I already had internal ads enabled, but no internal ads set), and suddenly ads started showing on my app (not only internal ads).

我想的一切完全使工作? :)

I guess everything altogether made it work?! :)

谢谢大家!

推荐答案

你是不是定位广告的RelativeLayout的(他们需要一个layout_above或layout_below或任何指定到哪里可以把它们)。

You aren't positioning the ad's in the RelativeLayout (they need a layout_above or layout_below or whatever to specify where to put them).

也有对AdMob的,你可能想确保你匹配的最小尺寸,我觉得它像48dip的高度,至少,不能确定的水平是什么。

Also there is a minimum size for admob that you might want to ensure you match, I think it's like 48dip in height at least, not sure what the horizontal is.

最后,我不知道你想放置广告的,但它可能会更有意义在你的主框架布局,我有一个填充在我的应用程序中,我使用的广告视图底部

Lastly I don't know where you are trying to place your ad's, but it probably would make more sense in your main frame-layout, I have a padding at the bottom of my app which I use for the ad-view.

编辑:另外,如果您的应用程序是公开的检查广告收入。安卓pre 2.3允许广告被隐藏背后的观点,仍然注册点击。在我的广告甚至可见的任何人,我居然做了我最初的$ 1。

also if your app is public check for ad-revenue. Android pre 2.3 allowed ad's to be hidden behind views and still register clicks. I actually made my initial $1 before my ad's were even visible by anyone.