当前位置:  开发笔记 > 编程语言 > 正文

不要让AdMob在模拟器上运行(android 2.2)

如何解决《不要让AdMob在模拟器上运行(android2.2)》经验,为你挑选了1个好方法。

我只是想让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

谁有线索?



1> Christian Sc..:

我在建议的教程中尝试过(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运行时的模拟器?

推荐阅读
手机用户2402851335
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有