android - 解析 XML 时出错 : unbound prefix with admob ad

标签 android

我有一个看起来像这样的工作布局:

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

    <com.google.ads.AdView android:id="@+id/adView"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         ads:adUnitId="ca-app-pub-xxx/xxx"
                         ads:adSize="BANNER"
                         ads:testDevices="TEST_EMULATOR, xxx"
                         ads:loadAdOnCreate="true"/>

</LinearLayout>

现在我想删除 LinearLayout:

<?xml version="1.0" encoding="utf-8"?>
<com.google.ads.AdView android:id="@+id/adView"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         ads:adUnitId="ca-app-pub-9000079580883391/8483250253"
                         ads:adSize="BANNER"
                         ads:testDevices="TEST_EMULATOR, 4FBD7E211FFFF7D7"
                         ads:loadAdOnCreate="true"/>

然后我就遇到了错误。我知道我需要添加 xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 但我不知道在哪里

最佳答案

xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 将这两个添加到您的 Adview

关于android - 解析 XML 时出错 : unbound prefix with admob ad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19656201/

相关文章:

java - 通知一系列事件完成的监听器(启动同步服务)

android - 在 Windows 10 上使用 Cmake 编译 Heimdall

java - 使用字符串变量作为我想要播放的声音的名称,Java (Android)

android - 如何删除抽屉导航图标

java - Android多实例Activity

android - 如何在android中创建自定义形状的按钮

android - 隐藏应用程序图标并运行它

android - 将时间从时区 -500 转换为设备所在的时区

android - 为什么应用程序突然与某些设备不兼容?

java - UDP 发送总是以捕获结束