我只是想让admob运行并从这里测试不同的"工作"代码示例.它们都不起作用.
在我的活动中:
在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):
我得到的只是一个黑屏1秒钟.
在执行期间打印log(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: com.android.internal.view.IInputMethodClient$Stub$Proxy@450d4998 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: 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被激活.
我还通过实例化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: 08-09 10:49:20.397: WARN/InputManagerService(59): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@450d20b8 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
谁有线索?
我在建议的教程中尝试过(blog.kerul.net/2011/05/)
但我只得到一秒钟的黑色视图然后返回到android"桌面":
源看起来像这样:
活动类:
class StartActivity extends AdActivity{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); AdView adview = (AdView)findViewById(R.id.adView1); AdRequest re = new AdRequest(); re.addTestDevice(AdRequest.TEST_EMULATOR); re.setTesting(true); adview.loadAd(re); } ... }
风景:
是的,我用我真正的发布商ID替换了MY_PUB_ID
有什么遗漏?您使用哪个Android运行时的模拟器?