我已經包括在我的清單中的相關部分:麻煩廣告在AdMob
<meta-data android:value="123456789" android:name="ADMOB_PUBLISHER_ID" />
<!-- Track Market installs from AdMob ads -->
<receiver android:name="com.admob.android.ads.analytics.InstallReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" />'
和
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>'
ATTRS從一例子複製:
<?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>
我的佈局(這是一個標籤視圖順便說一句)是一個表在它自己的行:
xmlns:app="http://schemas.android.com/apk/res/com.icukansas.lenscalculator"
和
<TableRow>
<!-- Place an AdMob ad at the bottom of the screen. -->
<!-- It has white text on a black background. -->
<com.admob.android.ads.AdView
android:layout_span="4"
android:id="@+id/ad"
app:backgroundColor="#000000"
app:primaryTextColor="#FFFFFF"
app:secondaryTextColor="#CCCCCC"
app:keywords="security"
/>
</TableRow>
我然後調用:
public class myClass extends Activity implements AdListener{
公共無效的onCreate(捆綁savedInstanceState){ super.onCreate(savedInstanceState);
setContentView(R.layout.tab_thistab);
AdView ad = (AdView) findViewById(R.id.ad);
ad.setAdListener(this);
每當我在日誌中遇到錯誤ToReceiveAd錯誤。
我敢肯定它的東西很容易我缺少:)
這個問題使用attrs.xml,這可能意味着它使用Admob 4.0.4或更早的版本。 4.1.0在[此Google小組討論]中描述了一些變更(http://groups.google.com/group/google-admob-ads-sdk/browse_thread/thread/3b885d3fe5bb21a5)(查找Tim的帖子)。 – idbrii 2011-06-17 17:07:25