AdMob: Missing required XML attribute adUnitID(AdMob:缺少必需的 XML 属性 adUnitID)
问题描述
我是广告方面的新手,我无法让它发挥作用.我已经完成了 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:AdMob:缺少必需的 XML 属性 adUnitID


基础教程推荐
- AdMob 广告未在模拟器中显示 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01