今天,我决定更新Android Studio,因为我安装的3.1版本似乎有些过时了。升级后,由于某种error: <item> inner element must either be a resource reference or empty.
完整输出:
Android resource compilation failed
Output: E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2400: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2401: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2402: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2403: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2404: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2405: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2406: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2407: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2408: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2409: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2410: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2411: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2412: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2414: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2415: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2416: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2418: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2419: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2420: error: <item> inner element must either be a resource reference or empty.
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2421: error: <item> inner element must either be a resource reference or empty.
Command: C:\Users\Manuel\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\f6068c12ec105318abf65b42f5ee35d5\aapt2-3.2.0-4818971-windows\aapt2.exe compile --legacy \
-o \
E:\Desktop\testandroidstudio\app\build\intermediates\res\merged\debug \
E:\Desktop\testandroidstudio\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon: AAPT2 aapt2-3.2.0-4818971-windows Daemon #0
错误指向构建文件values.xml
,对其进行检查,我认为问题可能出在我的arrays.xml
文件上。
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="dice_types">
<item>@string/dice4</item>
<item>@string/dice6</item>
<item>@string/dice8</item>
<item>@string/dice10</item>
<item>@string/dice12</item>
<item>@string/dice20</item>
<item>@string/dice100</item>
</string-array>
<string-array name="dice_types_int">
<item>4</item>
<item>6</item>
<item>8</item>
<item>10</item>
<item>12</item>
<item>20</item>
<item>100</item>
</string-array>
<string-array name="spell_numbers">
<item>@string/spell_level_0</item>
<item>@string/spell_level_1</item>
<item>@string/spell_level_2</item>
<item>@string/spell_level_3</item>
<item>@string/spell_level_4</item>
<item>@string/spell_level_5</item>
<item>@string/spell_level_6</item>
<item>@string/spell_level_7</item>
<item>@string/spell_level_8</item>
<item>@string/spell_level_9</item>
</string-array>
<string-array name="ability_shorts">
<item>STR</item>
<item>DEX</item>
<item>CON</item>
<item>INT</item>
<item>WIS</item>
<item>CHA</item>
</string-array>
</resources>
我用Google搜索了一下,发现错误是由这样解析的项目引起的:
<item name="item_1" type="id">Item 1</item>
,可以通过使用以下代码替换代码来解决:
<item name="item_1" type="id"/>
但是我应该如何处理字符串数组?
答案 0 :(得分:0)
听起来您实际上无法将硬编码值放入item标签内。将它们放在@strings文件和@integers文件中,然后在项目标签中引用它们?