Don';无法在emulator(android 2.2)上运行AdMob
我只是想让admob运行,并从这里测试不同的“工作”代码示例。 它们都不起作用 在活动中,我有: oncreate() 在视图定义中,我插入了以下内容(是而不是myPubID,实际上是我的真实PubID): 并在以下日志中获得相同的行为:Don';无法在emulator(android 2.2)上运行AdMob,android,android-emulator,admob,Android,Android Emulator,Admob,我只是想让admob运行,并从这里测试不同的“工作”代码示例。 它们都不起作用 在活动中,我有: oncreate() 在视图定义中,我插入了以下内容(是而不是myPubID,实际上是我的真实PubID): 并在以下日志中获得相同的行为: 08-09 10:49:18.367: INFO/ActivityManager(59): Start proc de.syrtec.android.bogloid for activity de.syrtec.android.bogloid/.StartSe
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: 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
08-09 10:49:18.367:INFO/ActivityManager(59):为activity de.syrtec.android.bogloid/startSite:pid=4543 uid=10043 gids={3003}
08-09 10:49:19.297:错误/Ads(4543):无法获取currentAdManager。
08-09 10:49:19.797:WARN/ActivityManager(59):历史记录{44fe4350 de.syrtec.android.bogloid/.startsite}的活动暂停超时
08-09 10:49:20.067:INFO/Ads(4543):要在该设备上获取测试广告,请调用adRequest.addTestDevice(adRequest.test\u仿真器);
08-09 10:49:20.379:INFO/Ads(4543):adrenquesturlhtml:您需要将此字符串置于//不知道为什么您的测试设备的代码中。我更喜欢在测试时使用setTesting(true),但您知道。问题可能是这样的
哦,我看到你的程序无法接收广告,因为广告清单有问题
将其放置在com.google.ads.adView部分的布局中:
xmlns:ads=”http://schemas.android.com/apk/lib/com.google.ads"
别忘了带互联网许可证去你的舱单
希望能有帮助
编辑:我不确定这是否是您的问题,但我认为这会有所帮助。缺乏库存意味着AdMob没有任何广告可供提供,如果您的帐户是新的,这是常见的,一段时间后,您的填充率将增加,并将提供更多的广告。
如果您在AdMob网站/应用程序页面中看到绿色状态灯,您不必担心
尝试添加adsense以提高填充率
编辑:错过你已经启用了adsense我在建议的教程中尝试过()
但我只得到一个黑色视图一秒钟,然后返回到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);
}
...
}
观点:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/adView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
ads:adSize="BANNER"
ads:adUnitId="MY_PUB_ID" />
</LinearLayout>
是的,我用我真正的出版商ID替换了我的酒吧ID
少了什么吗?
你在哪个Android运行时使用哪个模拟器?我有过这样的经历:应用程序崩溃并显示这样的消息——“错误膨胀class com.admob.ads.AdView”。通过一些研究和测试,我得出以下XML属性来显示AdView
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/bg1"
android:orientation="vertical" >
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="738a44d913034b9f"
/>
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/txtsearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textMultiLine"
android:maxLines="3"
android:minLines="1"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical" />
</TableRow>
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btnkamus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/search" />
<Button
android:id="@+id/btnsearch"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Kesan" />
<Button
android:id="@+id/btncadang"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Cadang" />
</TableRow>
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>`
`
`
完整的教程在这里-我更喜欢用r.addTestdevice(phoneID)设置测试设备,然后我的开发手机会收到测试广告,我不需要在发布时将setTesting()还原为False。此外,如果您使用多个开发人员电话和模拟器,您只需广告他们的ID,就可以了。至于“//没有线索…”,这行没有问题:-)谢谢你的回答..我按照你的建议尝试了..得到了相同的行为和我最初的第二个日志输出可能会有帮助:至少我希望:)看起来很好..符合虚拟…所以它应该适合我;)。。。当我找到时间时,我会尝试一下。希望它会有所帮助,如果你能用它做点什么,请回信:)我得到了一个绿色状态,通知:活动:你的网站目前正在向AdMob发送查看请求。(我不明白我的网站为什么要与admob交谈…)我能做些什么来提高填充率…以显示单个广告?…与我的网站的连接实际上是为了什么,因为它与我的应用程序无关?你的网站是admob对你的出版物、应用程序、移动网站等的通用术语。。。这意味着你的应用程序正在与admobso my通信。我的网站的url仅用作我的应用程序的标识符,对吗?我不确定你在这里指的是什么。。。如果您查看admob站点的设置,它应该是“android应用程序”类型网站url应该是你在android market上的应用程序的urlmarket://details?id=com.your.appI 只是想让sdk来测试admob…所以我不得不在那里放一个url来下载它…当我不知道我的应用程序外观如何或是否工作时,我不会将其投放市场;)隐马尔可夫模型。。。非常有趣。这是您的全部项目,还是有更多的代码?首先删除你的re.addTestDevice(addRequest.TEST\u仿真器);如果使用re.setTesting(true)行,则不需要is。您是否也尝试在Eclipse中创建另一个项目,或者这是第一个项目?也许,问题不在于代码,而在于Eclipse。谢谢:-)…现在测试广告显示为“成功!现在你已经准备好在应用程序Galaxy中旅行了”,那么如何处理真正的广告呢?我想这样做:1。拆下重新设置(正确)2。在app market 3上发布我的应用程序。将admob中的应用程序链接到应用程序的实际真实市场url是否仍然缺少或不正确?最后:D问题出在哪里?您是否只删除了re.addTestDevice?是,首先需要从项目中删除re.setTesting(true)行,然后发布它。我认为您不需要实际的市场url,您只需要在admob网站上显示的示例中写下您的包名。我很高兴能帮助你;)是的,我只删除了re.addTestDevice(addRequest.TEST\u仿真器);它成功了:)
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: 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
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);
}
...
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/adView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
ads:adSize="BANNER"
ads:adUnitId="MY_PUB_ID" />
</LinearLayout>
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/bg1"
android:orientation="vertical" >
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="738a44d913034b9f"
/>
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/txtsearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textMultiLine"
android:maxLines="3"
android:minLines="1"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical" />
</TableRow>
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btnkamus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/search" />
<Button
android:id="@+id/btnsearch"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Kesan" />
<Button
android:id="@+id/btncadang"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Cadang" />
</TableRow>
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>`