Android 解析XML未绑定前缀时出现Adview错误

Android 解析XML未绑定前缀时出现Adview错误,android,layout,xml-parsing,admob,Android,Layout,Xml Parsing,Admob,让AdMob工作我真是太辛苦了。我犯了一个又一个错误,并且不止一次地放弃了整件事。现在我从XML中得到一个错误,说它不能正确解析。这是目前的代码。我看了其他的答案,但我似乎不知道出了什么问题。如果有人能看看我的布局文件,让我知道我做错了什么,我将不胜感激。值得一提的是,我直接使用AdMob网站上的代码,这些代码适合我自己的应用程序 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" androi

让AdMob工作我真是太辛苦了。我犯了一个又一个错误,并且不止一次地放弃了整件事。现在我从XML中得到一个错误,说它不能正确解析。这是目前的代码。我看了其他的答案,但我似乎不知道出了什么问题。如果有人能看看我的布局文件,让我知道我做错了什么,我将不胜感激。值得一提的是,我直接使用AdMob网站上的代码,这些代码适合我自己的应用程序

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/AdLinearLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical" >

<!-- Ad Placeholder -->

<com.google.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ads:adSize="BANNER"
    ads:adUnitId="a15138b1a7adad2"
    ads:loadAdOnCreate="true"
    ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />

<ScrollView
    android:id="@+id/BaseScrollView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:id="@+id/baseVerticalLinearLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/LinearLayoutH1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="left"
                android:text="@string/Sad" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="right"
                android:text="@string/Happy" />
        </LinearLayout>

        <SeekBar
            android:id="@+id/happinessBarID"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:max="@integer/SliderMax"
            android:progress="@integer/SliderDefault" />

        <LinearLayout
            android:id="@+id/LinearLayoutH2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/textView3"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="left"
                android:text="@string/Tired" />

            <TextView
                android:id="@+id/textView4"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="right"
                android:text="@string/Awake" />
        </LinearLayout>

        <SeekBar
            android:id="@+id/energyBarID"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:max="@integer/SliderMax"
            android:progress="@integer/SliderDefault" />

        <LinearLayout
            android:id="@+id/LinearLayoutH3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/textView5"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="left"
                android:text="@string/Calm" />

            <TextView
                android:id="@+id/textView6"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="right"
                android:text="@string/Anxious" />
        </LinearLayout>

        <SeekBar
            android:id="@+id/anxietyBarID"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:max="@integer/SliderMax"
            android:progress="@integer/SliderDefault" />

        <LinearLayout
            android:id="@+id/LinearLayoutH4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/textView7"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="left"
                android:text="@string/No_Pain" />

            <TextView
                android:id="@+id/textView8"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="right"
                android:text="@string/Max_Pain" />
        </LinearLayout>

        <SeekBar
            android:id="@+id/painBarID"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:max="@integer/SliderMax"
            android:progress="@integer/SliderDefault" />

        <DatePicker
            android:id="@+id/datePicker1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TimePicker
            android:id="@+id/timePicker1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <EditText
            android:id="@+id/noteTextFieldID"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="@string/Note_Hint"
            android:inputType="textMultiLine"
            android:maxLength="@integer/NoteLimit" />

        <Button
            android:id="@+id/enterButtonID"
            android:layout_width="132dp"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:onClick="dialogPop"
            android:text="@string/EnterButtonText" />
    </LinearLayout>
</ScrollView>

更改:

android:ads="http://schemas.android.com/apk/lib/com.google.ads"


AdMob要求您使用其包中定义的属性。为了不必每次都输入那个URL,我们使用
xmlns
声明了一个XML名称空间,就像android一样。您在声明前面加了
android
而不是
xmlns
,这导致了您的错误。

将此行添加到布局中

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

就这些吗?为什么一定是这样?我问为什么,因为这将有助于我了解未来。拉加夫,包括这背后的原因,这样他/她就会知道,我相信他/她不会再犯这样的错误。哦哈哈!!!现在我觉得自己很愚蠢,但现在有道理了。非常感谢您提出的解决方案(更重要的是)及其背后的理由。是的,我不会再这么做了
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"