【问题标题】:Error in Android Studio xmlAndroid Studio xml 中的错误
【发布时间】:2018-10-24 19:15:36
【问题描述】:

今天我刚刚更新了我的 android studio...因为我在 xml 文件中遇到了更多错误

AGPBI: {"kind":"error","text":"error: 属性
\u0027android:contentScrim\u0027 未找到。","来源": [{"file":"C:\Users\priya\AndroidStudioProjects\MyApplication\app\src\main\res\layout\activity_main6.xml","position":{"startLine":12}}],"original" :"","tool":"AAPT"} AGPBI: {"kind":"error","text":"error: \u0027attr/actionBarSize\u0027 与属性 android:layout_height (attr) 不兼容 维度|枚举 [fill_parent\u003d4294967295, match_parent\u003d4294967295, wrap_content\u003d4294967294].","sources":[{"file":"C:\Users\priya\AndroidStudioProjects\MyApplication\app\src\main\res\layout\activity_main6.xml","position":{" startLine":22}}],"original":"","tool":"AAPT"} AGPBI: {"kind":"error","text":"error: 属性 \u0027android:srcCompact\u0027 不是 找到。","sources":[{"file":"C:\Users\priya\AndroidStudioProjects\MyApplication\app\src\main\res\layout\activity_main6.xml","position":{"startLine": 61}}],"original":"","tool":"AAPT"} AGPBI: {"kind":"error","text":"error: 属性 \u0027android:srcCompact\u0027 不是 找到。","sources":[{"file":"C:\Users\priya\AndroidStudioProjects\MyApplication\app\src\main\res\layout\activity_main6.xml","position":{"startLine": 99}}],"original":"","tool":"AAPT"} AGPBI: {"kind":"error","text":"error: 属性 \u0027android:srcCompact\u0027 不是 找到。","sources":[{"file":"C:\Users\priya\AndroidStudioProjects\MyApplication\app\src\main\res\layout\activity_main6.xml","position":{"startLine": 144}}],"原始":"","工具":"AAPT"} AGPBI: {"kind":"error","text":"error: 属性 \u0027android:srcCompact\u0027 不是 找到。","sources":[{"file":"C:\Users\priya\AndroidStudioProjects\MyApplication\app\src\main\res\layout\activity_main6.xml","position":{"startLine": 182}}],"原始":"","工具":"AAPT"} AGPBI: {"kind":"error","text":"error: 属性 \u0027android:srcCompact\u0027 不是 找到。","sources":[{"file":"C:\Users\priya\AndroidStudioProjects\MyApplication\app\src\main\res\layout\activity_main6.xml","position":{"startLine": 227}}],"原始":"","工具":"AAPT"}

FAILURE:构建失败并出现异常。

  • 出了什么问题: 任务 ':app:processDebugResources' 执行失败。

    处理资源失败,详见上面的 aapt 输出。

  • 尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。

  • 通过https://help.gradle.org获得更多帮助

29 秒后构建失败

我试图纠正它,但我不能......任何人都知道这个......谢谢


这是我的活动

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.kara.kavin.myapplication.Main6Activity">
<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="300dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
    android:id="@+id/collasingtoolbar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_scrollFlags="exitUntilCollapsed|scroll"
    android:contentScrim="?attr/colorPrimary"
    app:title="NEAT Patrol"
    app:expandedTitleMarginStart="48dp"
    app:expandedTitleMarginEnd="64dp"
    android:background="@drawable/sam">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbarid"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:layout_collapseMode="pin"
        android:layout_width="match_parent"
        android:layout_height="attr/actionBarSize"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="10dp"
        android:background="#fcfcfc"
        android:gravity="center"
        android:id="@+id/ll">
        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <android.support.v7.widget.CardView
                android:foreground="?android:attr/selectableItemBackground"
                android:clickable="true"
                android:id="@+id/bankcardId"
                android:layout_width="160dp"
                android:layout_height="190dp"
                android:layout_margin="10dp">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">
                    <ImageView
                        android:layout_width="64dp"
                        android:layout_height="64dp"
                        android:background="@drawable/cerclebackgroundpurple"
                        android:srcCompact="@drawable/ic_attach_money_black_24dp"
                        android:padding="10dp"/>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textStyle="bold"
                        android:layout_marginTop="10dp"
                        android:text="Banking"/>
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:background="@color/lightgray"
                        android:layout_margin="10dp"/>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:text="Check your bank activities"
                        android:padding="5dp"
                        android:textColor="@android:color/darker_gray"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:foreground="?android:attr/selectableItemBackground"
                android:clickable="true"
                android:layout_width="160dp"
                android:layout_height="190dp"
                android:layout_margin="10dp">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">
                    <ImageView
                        android:layout_width="64dp"
                        android:layout_height="64dp"
                        android:background="@drawable/cerclebackgroundpink"
                        android:srcCompact="@drawable/ic_lightbulb_outline_black_24dp"
                        android:padding="10dp"/>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textStyle="bold"
                        android:layout_marginTop="10dp"
                        android:text="Ideas"/>
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:background="@color/lightgray"
                        android:layout_margin="10dp"/>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:text="Check your bank activities"
                        android:padding="5dp"
                        android:textColor="@android:color/darker_gray"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <android.support.v7.widget.CardView
                android:foreground="?android:attr/selectableItemBackground"
                android:clickable="true"
                android:layout_width="160dp"
                android:layout_height="190dp"
                android:layout_margin="10dp">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">
                    <ImageView
                        android:layout_width="64dp"
                        android:layout_height="64dp"
                        android:background="@drawable/cerclebackgroundgreen"
                        android:srcCompact="@drawable/ic_control_point_black_24dp"
                        android:padding="10dp"/>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textStyle="bold"
                        android:layout_marginTop="10dp"
                        android:text="Add"/>
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:background="@color/lightgray"
                        android:layout_margin="10dp"/>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:text="Check your bank activities"
                        android:padding="5dp"
                        android:textColor="@android:color/darker_gray"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:foreground="?android:attr/selectableItemBackground"
                android:clickable="true"
                android:layout_width="160dp"
                android:layout_height="190dp"
                android:layout_margin="10dp">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:orientation="vertical">
                    <ImageView
                        android:layout_width="64dp"
                        android:layout_height="64dp"
                        android:background="@drawable/cerclebackgroundyello"
                        android:padding="10dp"
                        android:srcCompact="@drawable/ic_attach_file_black_24dp" />
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:text="Links"
                        android:textStyle="bold" />
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_margin="10dp"
                        android:background="@color/lightgray" />
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text="Check your bank activities"
                        android:textColor="@android:color/darker_gray" />
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <android.support.v7.widget.CardView
                android:foreground="?android:attr/selectableItemBackground"
                android:clickable="true"
                android:layout_width="340dp"
                android:layout_height="150dp"
                android:layout_margin="10dp">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">
                    <ImageView
                        android:layout_width="64dp"
                        android:layout_height="64dp"
                        android:background="@drawable/cerclebackgroundpurple"
                        android:srcCompact="@drawable/ic_wifi_black_24dp"
                        android:padding="10dp"/>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textStyle="bold"
                        android:layout_marginTop="10dp"
                        android:text="Add"/>
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:background="@color/lightgray"
                        android:layout_margin="10dp"/>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:text="Check your bank activities"
                        android:padding="5dp"
                        android:textColor="@android:color/darker_gray"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>
    </LinearLayout>
</android.support.v4.widget.NestedScrollView>

【问题讨论】:

  • 添加activity_main6.xml文件

标签: android xml


【解决方案1】:

使用 app 命名空间(在您的折叠工具栏中) 所以使用,

 app:contentScrim="@color/your_color"

而不是

 android:contentScrim

【讨论】:

    【解决方案2】:

    您需要解决 AAPT 向您指出的三件事:

    • attr/actionBarSize is incompatible with attribute android:layout_height - 你传递了一个字符串而不是一个引用。将 attr/actionBarSize 更改为 @attr/actionBarSize
    • android:srcCompact not found - 没有 srcCompact 之类的东西 :) 在你的 activity_main6.xml 的所有四个地方用 android:srcCompat 替换 android:srcCompact
    • android:contentScrim not found - android 命名空间中没有 contentScrim。您可能是指app:contentScrim,就像@santanu-sur 在他的回答中已经指出的那样。

    修复这三个问题,它应该可以编译了。

    【讨论】:

    • 你解决了所有这些问题吗?如果你有,你现在一定会收到不同的错误 - 可能类似但关于其他资源或不同文件。
    【解决方案3】:

    我从 VIEW 中删除了样式属性,问题解决了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-03
      相关资源
      最近更新 更多