错误:错误:”与属性android:background(attr)reference | color不兼容

weixin_38059392 2019-09-12 11:34:23
我无法运行我的应用程序并且某些属性无法识别,因为应用程序构建结果建议不支持资源.我如何修复所有资源值?它可能是依赖项中的问题吗? android工作室可以读取依赖和资源分配.它是如何相关的 到android资源的不兼容性问题这是我的xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:fab="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" > <android.support.v7.widget.Toolbar android:id="@+id/toolBar" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?attr/actionBarSize" app:contentInsetLeft="0dp" app:contentInsetStart="16dp" android:background="@color/colorPrimary" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/toolBar" android:id="@+id/add_reminder_layout_top" android:orientation="vertical" > <EditText android:layout_width="match_parent" android:layout_height="50dp" android:id="@+id/reminder_title" android:layout_marginLeft="32dp" android:layout_marginTop="10dp" android:hint="Name" android:textSize="20sp" android:minLines="1" android:background="@android:color/transparent" android:drawableLeft="@drawable/ic_person_black_24dp" android:drawablePadding="12dp" android:gravity="center|start" android:textColor="@android:color/background_dark" android:scrollHorizontally="false" android:textColorHint="@android:color/background_dark" android:inputType="textCapWords" android:layout_marginRight="16dp" /> <EditText android:layout_width="match_parent" android:layout_height="50dp" android:id="@+id/phone_no" android:layout_marginLeft="32dp" android:hint="phone Number" android:layout_marginTop="15dp" android:layout_marginBottom="10dp" android:textSize="20sp" android:background="@android:color/transparent" android:drawableLeft="@drawable/ic_phone_black_24dp" android:drawablePadding="12dp" android:gravity="center|start" android:textColor="@android:color/background_dark" android:scrollHorizontally="false" android:textColorHint="@android:color/background_dark" android:inputType="phone" android:layout_marginRight="16dp" /> </LinearLayout> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@+id/add_reminder_layout_top"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="72dp" android:layout_marginTop="8dp" android:text="@string/details" android:id="@+id/details" android:textSize="15sp" android:gravity="center_vertical" android:layout_marginLeft="72dp" android:textColor="@android:color/primary_text_light"/> <RelativeLayout android:layout_width="match_parent" android:layout_height="72dp" android:clickable="true" android:onClick="setDate" android:id="@+id/date" android:background="@drawable/ic_launcher_foreground" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/date_icon" android:layout_alignParentLeft="true" android:layout_marginLeft="16dp" android:layout_marginRight="32dp" android:src="@drawable/ic_date" android:layout_centerVertical="true"/> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_toRightOf="@+id/date_icon"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/date_text" android:textSize="15dp" android:text="@string/date"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/set_date" android:textSize="15dp" /> </LinearLayout> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="72dp" android:clickable="true" android:onClick="setTime" android:id="@+id/time" android:background="?android:attr/selectableItemBackground"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/time_icon" android:layout_alignParentLeft="true" android:layout_marginLeft="16dp" android:layout_marginRight="32dp" android:src="@drawable/ic_time" android:layout_centerVertical="true"/> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_toRightOf="@+id/time_icon"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/time_text" android:textSize="15dp" android:text="@string/time"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/set_time" android:textSize="15dp" /> </LinearLayout> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="72dp" android:id="@+id/repeat"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/repeat_icon" android:layout_alignParentLeft="true" android:layout_marginLeft="16dp" android:layout_marginRight="32dp" android:src="@drawable/ic_repeat" android:layout_centerVertical="true"/> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/repeat_ll" android:layout_toRightOf="@+id/repeat_icon"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/repeat_text" android:textSize="15dp" android:text="@string/repeat"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/set_repeat" android:textSize="15dp" /> </LinearLayout> <Switch android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/repeat_switch" android:layout_centerVertical="true" android:layout_alignParentRight="true" android:layout_marginRight="16dp" android:layout_marginLeft="8dp" android:onClick="onSwitchRepeat" android:checked="true" android:textOn="On" android:textOff="Off"/> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="72dp" android:clickable="true" android:onClick="setRepeatNo" android:id="@+id/repeat_no" android:background="" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/repeat_no_icon" android:layout_alignParentLeft="true" android:layout_marginLeft="16dp" android:layout_marginRight="32dp" android:src="@drawable/ic_repeat_no" android:layout_centerVertical="true"/> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_toRightOf="@+id/repeat_no_icon"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/repeat_no_text" android:textSize="15dp" android:text="@string/repetition_interval"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/set_repeat_no" android:textSize="15dp" /> </LinearLayout> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="72dp" android:clickable="true" android:onClick="selectRepeatType" android:id="@+id/repeat_type" android:background="@mipmap/ic_launcher" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/repeat_type_icon" android:layout_alignParentLeft="true" android:layout_marginLeft="16dp" android:layout_marginRight="32dp" android:src="@drawable/ic_repeat_no" android:layout_centerVertical="true"/> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_toRightOf="@+id/repeat_type_icon"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/repeat_type_text" android:textSize="15dp" android:text="@string/type_of_repetitions"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/set_repeat_type" android:textSize="15dp" /> </LinearLayout> </RelativeLayout> </LinearLayout> </ScrollView> <com.getbase.floatingactionbutton.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/starred1" android:clickable="true" android:onClick="selectFab1" fab:fab_icon="@drawable/notification_off" fab:fab_colorNormal="@color/colorAccent" fab:fab_colorPressed="@color/colorPrimary" app:fab_size="mini" android:layout_alignParentRight="true" android:layout_marginTop="170dp" android:layout_centerHorizontal="true" android:layout_marginLeft="5dp"/> <com.getbase.floatingactionbutton.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/starred2" android:clickable="true" android:onClick="selectFab2" fab:fab_icon="@drawable/notification_on" fab:fab_colorNormal="@color/colorAccent" fab:fab_colorPressed="@color/colorPrimary" app:fab_size="mini" android:layout_alignParentRight="true" android:layout_marginTop="170dp" android:layout_centerHorizontal="true" android:layout_marginLeft="5dp"/> <CheckBox android:id="@+id/checkBox_completed" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/add_reminder_layout_top" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginBottom="11dp" android:layout_marginLeft="48dp" android:layout_marginStart="48dp" android:text="Completed" /> <CheckBox android:id="@+id/checkBox_failed" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/checkBox_completed" android:layout_alignBottom="@+id/checkBox_completed" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_marginEnd="37dp" android:layout_marginRight="37dp" android:text="Failed" /> > 这是我的错误 Information:Gradle tasks [:app:generateReleaseSources, :app:mockableAndroidJar] C:\Users\ghjsk\AndroidStudioProjects\NavDrawer\app\src\main\res\layout\activity_add_reminder.xml Error:error: '' is incompatible with attribute android:background (attr) reference|color. Error:'' is incompatible with attribute android:background (attr) reference|color. Error:failed linking file resources. Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details Error:Execution failed for task ':app:processReleaseResources'. > Failed to execute aapt Information:BUILD FAILED in 18s Information:7 errors Information:0 warnings Information:See complete output in console
...全文
2414 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_43211478 2019-12-12
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android:id="@+menugroup/new_activity_menugroup"> <item android:id="@+menuitem/about" android:title="关于" android:icon="@android:drawable/ic_menu_info_details" /> <item android:id="@+menuitem/cancel" android:title="退出" android:icon="@android:drawable/ic_menu_close_clear_cancel" /> </group> </menu>
我的这段代码也出现了类似的报错。 Android resource linking failed D:\JDYdroid2\app\src\main\res\menu\menu_xml_file.xml:3: AAPT: error: '@+menugroup/new_activity_menugroup' is incompatible with attribute id (attr) reference. D:\JDYdroid2\app\src\main\res\menu\menu_xml_file.xml:4: AAPT: error: '@+menuitem/about' is incompatible with attribute id (attr) reference. D:\JDYdroid2\app\src\main\res\menu\menu_xml_file.xml:6: AAPT: error: '@+menuitem/cancel' is incompatible with attribute id (attr) reference. 该怎么解决啊
weixin_38065217 2019-09-12
  • 打赏
  • 举报
回复 1
你的RelativeLayout中有id:id / repeat_no的android:background =“”.删除或设置正确的值应解决问题.

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧