我只是想讓admob運行並測試不同的「工作」代碼示例。 他們都沒有工作。不要讓AdMob在模擬器上運行(android 2.2)
在活動中,我有:
的OnCreate()
AdView ad = (AdView) findViewById(R.id.ad);
AdRequest r = new AdRequest();
r.addTestDevice("X3XFX518X7DE1FD879XA5XXAX1AX8BXX"); //no clue why this string
ad.loadAd(r);
在我已插入視圖定義如下(是不是myPubID有實際上我真正的PUB ID):
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="<myPubID>"
ads:adSize="BANNER"/>
我得到的是1秒黑屏。
以下日誌(logcat的)執行
08-09 10:45:03.527: INFO/ActivityManager(59): Start proc de.syrtec.android.bogloid for activity de.syrtec.android.bogloid/.StartSeite: pid=4402 uid=10043 gids={3003}
08-09 10:45:04.887: ERROR/Ads(4402): Could not get currentAdManager.
08-09 10:45:05.397: WARN/InputManagerService(59): Window already focused, ignoring focus gain of: [email protected]
08-09 10:45:05.567: INFO/Ads(4402): To get test ads on this device, call adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
08-09 10:45:06.159: INFO/Ads(4402): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"preqs":0,"u_sd":1.5,"slotname":"********;</script></head><body></body></html>
08-09 10:45:07.528: WARN/webcore(4402): Can't get the viewWidth after the first layout
08-09 10:45:07.848: INFO/Ads(4402): Received ad url: <"url": "http://r.admob.com:80/ad_source.php?preqs=0&u_sd=1.5&slotname=*****: "null">
08-09 10:45:08.809: DEBUG/webviewglue(4402): nativeDestroy view: 0x2bbb30
08-09 10:45:08.818: INFO/Ads(4402): onFailedToReceiveAd(Ad request successful, but no ad returned due to lack of ad inventory.)
08-09 10:45:11.168: DEBUG/dalvikvm(3148): GC_EXPLICIT freed 32 objects/1640 bytes in 131ms
08-09 10:45:16.237: DEBUG/dalvikvm(272): GC_EXPLICIT freed 195 objects/12168 bytes in 137ms
我使用GoogleAdMobAdsSdk-4.1.1.jar和仿真器的Android 2.2中被打印。
在我的AdMob帳戶沒有過濾和AdSense被激活。
我也嘗試過通過instanciating AdView中,並將其與增加了rootlayout: (指http://code.google.com/mobile/ads/docs/android/fundamentals.html)
AdView adView = new AdView(this, AdSize.BANNER, "PUB_ID");
LinearLayout layout = (LinearLayout)findViewById(R.id.mainLayout);
layout.addView(adView);
adView.loadAd(new AdRequest());
,並得到了與以下日誌相同的行爲:
08-09 10:49:18.367: INFO/ActivityManager(59): Start proc de.syrtec.android.bogloid for activity de.syrtec.android.bogloid/.StartSeite: pid=4543 uid=10043 gids={3003}
08-09 10:49:19.297: ERROR/Ads(4543): Could not get currentAdManager.
08-09 10:49:19.797: WARN/ActivityManager(59): Activity pause timeout for HistoryRecord{44fe4350 de.syrtec.android.bogloid/.StartSeite}
08-09 10:49:20.067: INFO/Ads(4543): To get test ads on this device, call adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
08-09 10:49:20.379: INFO/Ads(4543): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script*****;</script></head><body></body></html>
08-09 10:49:20.397: WARN/InputManagerService(59): Window already focused, ignoring focus gain of: [email protected]
08-09 10:49:22.737: WARN/webcore(4543): Can't get the viewWidth after the first layout
08-09 10:49:22.957: INFO/Ads(4543): Received ad url: <"url": "http://r.admob.com:80/ad_source.php?preqs=0&u_sd=1.5&slotname=***** "null">
08-09 10:49:24.038: DEBUG/dalvikvm(4543): GC_FOR_MALLOC freed 3826 objects/234984 bytes in 154ms
08-09 10:49:24.058: DEBUG/webviewglue(4543): nativeDestroy view: 0x2c5320
08-09 10:49:24.058: INFO/Ads(4543): onFailedToReceiveAd(Ad request successful, but no ad returned due to lack of ad inventory.)
08-09 10:49:24.078: DEBUG/webviewglue(4543): nativeDestroy view: 0x2b81d0
有沒有人有線索?
嗯......非常有趣。這是你的所有項目,還是有更多的代碼?首先刪除你的re.addTestDevice(Adrequest.TEST_EMULATOR);如果使用re.setTesting(true)行,則不需要。您是否嘗試在Eclipse中創建另一個項目,或者這是第一個?問題可能不在於代碼,而在於Eclipse。 – Zwiebel
謝謝:-) ..現在測試廣告顯示打印「成功!現在您已準備好通過應用程序Galaxy」 那麼如何繼續實際的廣告? 我會做這樣的: 1.刪除re.setTesting(真) 2.發佈我的應用程序市場上AdMob的 3.聯動app的應用 的實際市場真實的URL是仍然存在缺少或不正確的東西? –
終於:D問題是什麼?你只是刪除了re.addTestDevice?是的,首先需要從項目中刪除re.setTesting(true)行,然後發佈它。我認爲你不需要實際的市場網址,你只需要將你的軟件包名稱寫入示例,就可以看到admob網站上顯示的內容。我很高興我可以幫你;) – Zwiebel