错误:(3)解析XML时出错:未绑定的前缀

时间:2015-03-08 19:54:14

标签: java android xml android-activity android-studio

我正在制作一个我想使用CardView的应用程序。

我下载了开源项目并根据我的需要应用更改,但我收到错误:

Error:(3) Error parsing XML: unbound prefix

Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Andrew\AppData\Local\Android\sdk\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 1

这是我的xml:

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

xmlns:tools="http://schemas.android.com/tools"


android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.MainActivity"
android:id="@+id/">

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:background="#e5e5e5">

    <!--<ImageView-->
        <!--android:src="@drawable/io2014_logo"-->
        <!--android:layout_width="200dp"-->
        <!--android:layout_height="100dp"-->
        <!--android:scaleType="fitCenter"-->
        <!--android:tint="#7000"-->
        <!--android:layout_gravity="center|top" />-->

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="false"
        android:id="@+id/">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="16dp"
            android:paddingLeft="16dp"
            android:paddingRight="16dp"
            android:paddingTop="100dp"
            android:clipToPadding="false">

            <com.example.ahsankhan.smsburst.test
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                iosched:cardBackgroundColor="#fff"
                iosched:cardCornerRadius="@dimen/card_corner_radius"
                iosched:cardElevation="@dimen/card_elevation"
                iosched:cardPreventCornerOverlap="false">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:padding="24dp">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"

                        android:fontFamily="@string/font_fontFamily_medium"
                        android:text="@string/welcome_to_google_i_o_app"
                        android:textColor="@color/theme_primary"
                        android:textSize="@dimen/text_size_xlarge"
                        android:textStyle="@integer/font_textStyle_medium"
                        android:id="@+id/" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="16dp"
                        android:autoLink="web"
                        android:text="@string/welcome_text"
                        android:textColor="@color/body_text_2"
                        android:textSize="@dimen/text_size_medium" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="16dp"
                        android:autoLink="web"
                        android:text="@string/eula_legal_text"
                        android:textColor="@color/body_text_2"
                        android:textSize="@dimen/text_size_medium" />

                </LinearLayout>
            </com.example.ahsankhan.smsburst.test>
        </FrameLayout>
    </ScrollView>

</FrameLayout>

<!-- Button bar -->
<LinearLayout
    android:layout_height="48dp"
    android:background="@color/theme_primary"
    android:layout_gravity="bottom"
    android:layout_width="match_parent">

    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent"
        android:background="?photoItemForeground"
        android:text="@string/decline"
        android:textColor="#8fff"
        android:textSize="@dimen/text_size_medium"
        android:textStyle="@integer/font_textStyle_medium"
        android:fontFamily="@string/font_fontFamily_medium"
        android:textAllCaps="true"
        android:id="@+id/button_decline" />

    <Button
        android:id="@+id/button_accept"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent"
        android:background="?photoItemForeground"
        android:text="@string/accept"
        android:textSize="@dimen/text_size_medium"
        android:textStyle="@integer/font_textStyle_medium"
        android:fontFamily="@string/font_fontFamily_medium"
        android:textAllCaps="true"
        android:textColor="#fff" />

</LinearLayout>
</LinearLayout>

这是我的build.gradle文件:

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.example.ahsankhan.smsburst"
    minSdkVersion 9
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 
file('proguard-project.txt')
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}

1 个答案:

答案 0 :(得分:0)

您需要在父布局中添加android xmlns属性,如:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:iosched="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    ...