问题描述
我是广告方面的新手,我无法让它发挥作用.我已经完成了 http:///code.google.com/intl/nl-NL/mobile/ads/docs/android/banner_xml.html.
I'm new to the ad stuff, and I can't get it working. I've done what's stated at http://code.google.com/intl/nl-NL/mobile/ads/docs/android/banner_xml.html.
这是我的 main.xml:
This is my 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 -->
这是我在 res/values 中的 attrs.xml:
This is my attrs.xml in 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>
运行应用时出现以下错误:
The following error occurs when I run the app:
XML 布局中的 adSize 参数无效:-1.默认为横幅
Invalid adSize paramter in XML layout: -1. Defaulting to BANNER
AdView 缺少必需的 XML 属性 adUnitId.
AdView missing required XML attribute adUnitId.
我做错了什么?
推荐答案
还在纠结的朋友可以试试 xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
.
Anyone who still struggle with it may try xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
.
这篇关于AdMob:缺少必需的 XML 属性 adUnitID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!