![](/img/trans.png)
[英]Error: No resource identifier found for attribute 'showsAsAction' in package 6
[英]Error:(4) No resource identifier found for attribute 'id' in package
我為工具欄添加的菜單項出現此錯誤。
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res-auto"
xmlns:xmls="http://schemas.android.com/apk/res/android">
<item
android:icon="@drawable/ic_camera_iris_white_36dp"
android:id="@+id/video_camera"
android:showAsAction="always"
android:title="@string/menu_camera_label"></item>
</menu>
關於如何解決此問題的任何想法? 這是構建錯誤
> Error:(4) No resource identifier found for attribute 'id' in package
> 'com.google.rabbit'
>
> Error:Execution failed for task ':app:processDebugResources'.
> > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command
> 'C:\Users\sagar_000\AppData\Local\Android\sdk\build-tools\23.0.1\aapt.exe''
> finished with non-zero exit value 1
最后
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
然后Clean-Rebuild-Sync 。
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<item
android:icon="@drawable/ic_camera_iris_white_36dp"
android:id="@+id/video_camera"
app:showAsAction="always"
android:title="@string/menu_camera_label"></item>
</menu>
<menu 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"
tools:context="com.sixmod.MainActivity">
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
<item
android:id="@+id/title"
android:orderInCategory="100"
android:title="@string/titlename"
app:showAsAction="always" />
<item
android:id="@+id/video_camera"
android:icon="@drawable/ic_camera_iris_white_36dp"
android:showAsAction="always"
android:title="@string/menu_camera_label"/>
</menu>
錯誤:(4)在包'com.google.rabbit'中找不到屬性'id'的資源標識符
根據編譯時錯誤,您的xml中的命名空間錯誤
<menu xmlns:android="http://schemas.android.com/apk/res-auto"
xmlns:xmls="http://schemas.android.com/apk/res/android">
應該
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
使用以下代碼解決了此類問題:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/tools"
xmlns:android1="http://schemas.android.com/apk/res/android">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.