2013-04-16 100 views
0

我試圖在我開發的應用中添加AdMob。Admob未顯示

這是我的xml:

<LinearLayout 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    tools:context=".MainActivity" > 
    <com.google.ads.AdView 
     xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads" 
     android:id="@+id/ad" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     googleads:adSize="BANNER" 
     googleads:adUnitId="###########" /> 
</LinearLayout> 

和我的onCreate方法的代碼:

//ads 
AdView adView = (AdView) findViewById(R.id.ad); 
adView.loadAd(new AdRequest()); 

logcat中給出了這樣的:

Received ad url <url: http://googleads..... 

所以它以某種方式工作,但我的應用程序,我從未看到任何橫幅。你有什麼想法發生了什麼?

我已經按照這個教程: http://androcode.es/2012/05/monetizando-nuestras-apps-admob-en-android/ Aswel作爲http://developer.android.com/intl/es/training/monetization/ads-and-ux.html

但沒有運氣。

編輯: 哦,忘了提,我已經在明顯的這兩行:

<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 

舉例來說,如果我刪除任何這些權限中,AD是SHOWN說缺少一些權限。所以我認爲佈局很好。

EDIT2: 也試圖爲測試目的此代碼,它的發生完全一樣:

adRequest.addTestDevice("#############"); 

EDIT3: 我讀過,這可能需要很長時間還是第一次。需要多長時間?因爲我等了大約30分鐘。 logcat會說它收到廣告嗎?

回答

0

解決了它。顯然它在仿真器上工作: 在xml文件中加入了這個:

googleads:loadAdOnCreate="true"