2017-02-11 168 views
1

我在我的活動xml中使用了以下視圖。Android AdMob橫幅廣告未顯示

<com.google.android.gms.ads.AdView 
    android:id="@+id/adView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    ads:adSize="BANNER" 
    ads:adUnitId="ca-app-pub-6844894412719021~8904567900"> 
</com.google.android.gms.ads.AdView> 
+0

我不確定您的代碼是否正確,但我發現的一件事是,我自己的廣告加載至少需要一分鐘。嘗試等待一會兒,看看你是否發現任何東西 – Eames

+1

歡迎來到Stack Overflow。請提供更多信息。你所得到的不足以說明問題所在。如果您不確定要提供哪些內容,請首先按照AdMob設置應用的所有說明進行操作。 –

回答

1

您的adUnitId似乎是不正確的。你通過電子郵件得到了嗎? 您應該使用下面的應用ID(與/替換〜)

ads:adUnitId="ca-app-pub-6844894412719021/8904567900"> 
1

嘗試添加到您的xml:

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

和搖籃:

compile 'com.google.android.gms:play-services-ads:9.8.0' 
+0

你怎麼知道OP還沒有?他們沒有提供足夠的信息。 –

0

它看起來像你正在使用app_id而不是banner_id。

<string name="app_id">ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx</string> 
<string name="banner_id">ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx</string> 

這兩個值彼此不同。

0

檢查您是否擁有最新版本的adMob和GooglePlayServices庫。