Android Studio 中 NFC 技术过滤器不支持的类型技术列表
Unsupported type tech-list in Android Studio for NFC tech-filter
在 Eclipse 中,这项技术-filter.xml 工作正常,
但在 Android Studio 中它在编译时给出错误:
Error:Execution failed for task ':app:mergeDebugResources'. > Path-to-project\app\src\main\res\values\tech_filter.xml: Error: Unsupported type 'tech-list'
技术-filter.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>
有人遇到过这个问题吗?有解决办法吗?
技术列表不是价值资源。您需要将其放在 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" />
在 Eclipse 中,这项技术-filter.xml 工作正常, 但在 Android Studio 中它在编译时给出错误:
Error:Execution failed for task ':app:mergeDebugResources'. > Path-to-project\app\src\main\res\values\tech_filter.xml: Error: Unsupported type 'tech-list'
技术-filter.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>
有人遇到过这个问题吗?有解决办法吗?
技术列表不是价值资源。您需要将其放在 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" />