簡體   English   中英

錯誤:(4)在包中找不到屬性“ id”的資源標識符

[英]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
  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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM