【发布时间】:2011-03-02 23:58:39
【问题描述】:
我目前正在开发一个应用程序并决定尝试 Admob 广告。
不幸的是,在遵循 Admob 的指南(非常简单,做得很好)之后,无论是在模拟器上还是在手机 (HTC Desire) 上运行它,我都没有收到任何广告。奇怪的是,广告在数百次尝试中展示了几次(我真的是指几次)。在 Admob 上查看我的帐户后,我发现该应用有 6000 个请求。
我开始了一个新的应用程序,从零开始,没有任何变化。
有什么线索吗?
这是我到目前为止所做的:
添加了 Admob 的库 JAR。
-
在我的清单中添加了这些(使用正确的 ID):
meta-data android:value="axxxxxxxxxxxxx" android:name="ADMOB_PUBLISHER_ID" / uses-permission android:name="android.permission.INTERNET" / -
在
res/values中创建了一个attrs.xml文件,内容如下:?xml version="1.0" encoding="utf-8"?> resources> declare-styleable name="com.admob.android.ads.AdView"> attr name="backgroundColor" format="color" /> attr name="primaryTextColor" format="color" /> attr name="secondaryTextColor" format="color" /> attr name="keywords" format="string" /> attr name="refreshInterval" format="integer" /> /declare-styleable> /resources> -
在我的布局中添加了以下内容 (
RelativeLayout):-
在 RelativeLayout 行下方,使用正确的应用程序名称而不是 xxxx:
xmlns:app="http://schemas.android.com/apk/res/com.me.xxxx"和:
com.admob.android.ads.AdView android:id="@+id/ad" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" app:backgroundColor="#000000" app:primaryTextColor="#FFFFFF" app:secondaryTextColor="#CCCCCC" />
-
-
由于上述方法无效,我尝试了以下方法,但也没有成功:
AdView example_adview = (AdView) findViewById(R.id.ad); example_adview.setVisibility(AdView.VISIBLE); example_adview.requestFreshAd();
【问题讨论】:
-
这个问题正在使用 attrs.xml,这可能意味着它正在使用 Admob 4.0.4 或更早版本。 4.1.0 在this google groups discussion 中描述了一些更改(查找 Tim 的帖子)。