开始使用AdMob的为Android - 困惑的文档 [英] getting started with admob for android - confused about documentation

查看:245
本文介绍了开始使用AdMob的为Android - 困惑的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始考虑将Admob的广告到Android应用程序我建设。到目前为止,还没有好。我一直在下面的,我从AdMob的网站下载的AdMod_Android_SDK_Instructions.pdf的例子,但也很困惑。第7页我看到import语句引用包作为com.admob.android.ads - 但我下载了SDK,包是com.google.ads - 这是来自前谷歌收购AdMob的一个吃剩的?它接着调用方法 dView.requestFreshAd(); - 这不会在最新的code存在。 请有人可以帮我出了一些code的实际工作?我从logcat的特定错误是:

I just started looking into putting Admob ads into the android app I'm building. So far, no good. I've been following the example in the AdMod_Android_SDK_Instructions.pdf that I downloaded from the adMob website, but am confused. On page 7 I see the import statements refer to the package as com.admob.android.ads - but in the SDK I downloaded, the package is com.google.ads - is this a leftover from before google acquired admob? It then goes on to call the method adView.requestFreshAd(); - which does not exist in the latest code. Please can someone help me out with some code that actually works? My specific errors from logcat are:

AD浏览报失踪所需的XML属性adUnitId。

AdView missing required XML attribute adUnitId.

...然后在我称之为 adView.loadAd(新AdRequest());我得到的:

... then after I call adView.loadAd(new AdRequest()); i get:

Invalid unknown request error: Cannot determine request type.  Is your ad unit Id correct?
onFailedToReceiveAd(Invalid Google Ad request).

任何帮助,很多AP preciated! 谢谢你。

Any help, much appreciated! Thanks.

推荐答案

截至4.1.0,

mob1lejunkie是完全正确的,你可以删除

mob1lejunkie is perfectly right, you can remove

  • attrs.xml
  • 的背景下,primarytextcolor,secondarytextcolor属性(与AdMob提供的网站定义他们的应用程序的管理设置选项卡上)
  • 删除命名空间的xmlns:从主布局的myapp在XML文件中,并通过的xmlns更换:广告(照顾在这里!新的xmlns不在/ APK / RES但APK / lib中)
  • 更改adUnitID和adSize的命名空间中的AD浏览报XML片段

所以这里是一个使用XML片断与AdMob的4.1.0:

so here is a working xml snippet with admob 4.1.0 :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="fill_parent"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads">

    <com.google.ads.AdView android:id="@+id/ad"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adUnitId="a14d7f7d2180609"
        ads:adSize="BANNER" />
</RelativeLayout>

是不是从谷歌略显清淡问开发者的地方放一个新的code和使用一个尚未记录由谷歌自己一个librairy?这让我想起了adwhirl冒险我......

Isn't it a bit light from google to ask devs to put in place a new code and use a librairy that is not yet documented by google themselves ? It reminds me of the adwhirl adventure...

不过,我必须说,我很高兴谷歌把在地方,卸下attrs.xml的东西。这是很容易使用AdMob的,在Android项目继承。

Nevertheless, I must say I am glad google put that in place and remove the attrs.xml stuff. It is much easier to use admob with project inheritance in android.

此外,对于使用多adviews在一个项目中,请注意,在此版本中,现在可以加你AdMob的ID在你的应用程序的strings.xml文件要求在此线程:<一href="http://groups.google.com/group/google-admob-ads-sdk/browse_thread/thread/c57917b4491a0c1">http://groups.google.com/group/google-admob-ads-sdk/browse_thread/thread/c57917b4491a0c1

Also, with respect to using multiple adviews in a project, please note that with this release, it is now possible to add you admob id in the strings.xml file of your application as requested on this thread : http://groups.google.com/group/google-admob-ads-sdk/browse_thread/thread/c57917b4491a0c1

只要把这种方式在你的XML布局为您的所有adviews:

Just put it this way in your xml layouts for all your adviews :

ads:adUnitId="@string/admob_unit_id"

然后

<string name="admob_unit_id">a14d7f7d2180609</string>

在您的strings.xml文件,该文件的所有其他本地化版本。 这会给你一个集中的位置,在所有你的意见输入您的AdMob ID。

in your strings.xml file and all other localized versions of this file. This will give you a single centralized location to enter your admob id in all your views.

大版本确实如此。

问候,  Steff

Regards, Steff

这篇关于开始使用AdMob的为Android - 困惑的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆