2016-06-13 41 views
1

在Eclipse中,这个技术含量的filter.xml工作正常,但 Android Studio中在编译时给出错误:不支持的类型高科技列表Android Studio中的NFC技术过滤

 
Error:Execution failed for task ':app:mergeDebugResources'. > Path-to-project\app\src\main\res\values\tech_filter.xml: Error: Unsupported type 'tech-list' 

高科技过滤器.XML:

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> 
    <tech-list> 
     <tech>android.nfc.tech.IsoDep</tech> 
    </tech-list> 
</resources> 

的AndroidManifest.xml:

<activity android:name=".MainActivity"> 
    <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 

     <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
    <intent-filter> 
     <action android:name="android.nfc.action.TECH_DISCOVERED"/> 
    </intent-filter> 
    <meta-data 
     android:name="android.nfc.action.TECH_DISCOVERED" 
     android:resource="values/tech_filter" /> 
</activity> 

有没有人遇到过这个问题?有没有解决这个问题的方法?

回答

2

技术列表不是价值资源。您需要将其置于res/xml/之下。因此,你tech_filter.xml的路径需要

app/src/main/res/xml/tech_filter.xml 

,并为它的清单条目是这样的:

<meta-data 
    android:name="android.nfc.action.TECH_DISCOVERED" 
    android:resource="@xml/tech_filter" /> 
+0

感谢的人,你保存一天! –

+0

@AbrahamPutraPrakasa太好了。不过,我想知道为什么这会在你的Eclipse项目中引起轰动...... –