Getting started with AdMob for Android – confused with documentation

I'm just beginning to think about putting AdMob ads into the Android application I'm building. So far, it's not good. I've been paying attention to the admod I downloaded from the AdMob website_ Android_ SDK_ On page 7, I saw the import statement referring to the package as com.admob.android.ads - but in the SDK I downloaded, the package is com.google.ads - is this the rest before Google obtained AdMob? Then continue to call the method adview. Requestfreshad(); – The latest code does not exist. Can someone help me solve some practical and useful code? My specific error on logcat is:

Adview is missing the required XML attribute adunitid

... then 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).
@H_301_13@

任何帮助,非常感谢!
谢谢.

解决方法:

自4.1.0起,

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

> attrs.xml
> background,primarytextcolor,secondarytextcolor属性(并在应用程序的管理设置选项卡上从admob网站定义它们)
>从xml文件中的主布局中删除名称空间xmlns:myapp,并将其替换为xmlns:ads(请注意这里!!新的xmlns不在/ apk / res中,但是在apk / lib中)
>在adView xml代码段中更改adUnitID和adSize的命名空间

所以这是一个使用admob 4.1.0的工作xml片段:

<?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>
@H_301_13@

是不是谷歌要求开发人员设置一个新的代码并使用谷歌尚未记录的图书馆?它让我想起了adwhirl冒险……

不过,我必须说我很高兴谷歌把它放到位并删除attrs.xml的东西.在android中使用admob和项目继承要容易得多.

此外,关于在项目中使用多个广告浏览量,请注意,在此版本中,现在可以根据此线程的请求在应用程序的strings.xml文件添加admob id:http://groups.google.com/group/google-admob-ads-sdk/browse_thread/thread/c57917b4491a0c1

只需将此方式放在xml布局中,即可获得所有广告评论

ads:adUnitId="@string/admob_unit_id"
@H_301_13@

然后

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

在strings.xml文件和此文件的所有其他本地化版本中.
这将为您提供一个集中的位置,以便在您的所有视图中输入您的admob ID.

确实很棒.

问候,
 Steff

总结

以上是编程之家为你收集整理的开始使用admob for android – 对文档感到困惑全部内容,希望文章能够帮你解决开始使用admob for android – 对文档感到困惑所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
喜欢与人分享编程技术与工作经验,欢迎加入编程之家官方交流群!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>