微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Android – AdMob:缺少必需的XML属性adUnitID

我是新的广告内容,我不能让它工作.
我在 http://code.google.com/intl/nl-NL/mobile/ads/docs/android/banner_xml.html做了什么.

这是我的main.xml:

<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="com.niek.runningapp"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="#FFFFFF"
    android:stretchColumns="1">
<!-- more stuff-->
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <com.google.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ads:adUnitId="a14da18492dd1f0"
            ads:adSize="BANNER" />
    </TableRow>
<!-- More stuff -->

这是我的resrs.xml在res / values:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <declare-styleable name="com.google.ads.AdView">
      <attr name="adSize">
          <enum name="BANNER" value="1"/>
          <enum name="IAB_MRECT" value="2"/>
          <enum name="IAB_BANNER" value="3"/>
          <enum name="IAB_leaderBOARD" value="4"/>
      </attr>
      <attr name="adUnitId" format="string"/>
  </declare-styleable>
</resources>

运行应用程序时出现以下错误

Invalid adSize paramter in XML layout: -1. Defaulting to BANNER

AdView missing required XML attribute adUnitId.

我究竟做错了什么?

解决方法

任何仍然努力的人都可以尝试xmlns:ads =“http://schemas.android.com/apk/lib/com.google.ads”.

原文地址:https://www.jb51.cc/android/311258.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐