2014-03-30 119 views
3

Android讓我完全無所適從。 Android的小白,我認爲它表明:錯誤:錯誤:沒有找到與給定名稱相匹配的資源('資源'值爲'@ xml/device_filter')

我得到在Android清單文件中的以下錯誤:

error: Error: No resource found that matches the given name (at 'resource' with value '@xml/device_filter').

我已經沒有複製和粘貼設備文件手動重新輸入這兩個清單文件和XML /。用十六進制編輯器查看這兩個文件,看看是否有任何潛伏的奇數字符,但是零,沒有。我嘗試重命名這兩個文件,將它們移動到其他文件夾,並在每次嘗試後再次返回並清理項目。 R也沒有生成。

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.cccu.stage2" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="12" 
    android:targetSdkVersion="19" /> 

<uses-feature android:name="android.hardware.usb.host" /> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
    <activity 
     android:name="com.cccu.stage2.FindDevice" 
     android:label="@string/app_name" 
     android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name="com.cccu.stage2.Stage2Activity" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /> 
     </intent-filter> 

     <meta-data 
      android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" 
      android:resource="@xml/device_filter" /> 
    </activity> 
</application> 

</manifest> 

這裏是device_filter.xml代碼:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
<usb-accessory manuafacturer="FTDI" model="FTDIUARTDemo" version="1.0" /> 
<usb-accessory manufacturer="FTDI" model="Android Accessory FT312D" version="1.0" /> 
<usb-device manufacturer="FTDI" vendor-id="1027" version="1.0" /> 
</resources> 
+1

您是否將您的device_filter.xml文件放在res/xml文件夾中? – joao2fast4u

+0

有完全相同的問題。複製來自http://developer.android.com/guide/topics/connectivity/usb/accessory.html的示例。剛剛發現另一個幾乎完全相同的例子,但有效。唯一的區別是我可以找到的是,在accessory_filter.xml文件中,編碼是作爲「utf-8」給出的,而「UTF-8」起作用。請參閱http://stackoverflow.com/questions/921533/is-the- XML聲明標籤區分大小寫 – user3666335

回答

0

我知道這個問題是古老的,但我發現它由於對Xamarin開發時有同樣的問題。在我的情況下,生成操作是不正確的device_filter.xml設置

  1. 選擇device_filter.xml在Solution Explorer
  2. 在文件的屬性窗格,設置生成操作AndroidResource

我檢查了Android Studio是否有類似的屬性,但沒有找到一個。然而,AS不是我的主要工具。我沒有檢查過去的版本或Eclipse。

相關問題