因此,我只是将我的应用程序转移到另一台笔记本电脑上,并且在尝试生成此错误时出现提示。请帮忙。我需要更改什么?
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
Output: C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:651: error: <item> inner element must either be a resource reference or empty.
C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:652: error: <item> inner element must either be a resource reference or empty.
Command: C:\Users\Rhylle Vincent\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\f919f683d074912d6e0f1b8bf0931ab0\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
-o \
C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\build\intermediates\res\merged\debug \
C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
Output: C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\src\main\res\values\ids.xml:4:5-54: AAPT: error: <item> inner element must either be a resource reference or empty.
C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\src\main\res\values\ids.xml:3:5-47: AAPT: error: <item> inner element must either be a resource reference or empty.
Command: C:\Users\Rhylle Vincent\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\f919f683d074912d6e0f1b8bf0931ab0\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
-o \
C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\build\intermediates\res\merged\debug \
C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 7s
ids.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="timebar" type="id">Time</item>
<item name="textClock" type="id">textClock</item>
</resources>
答案 0 :(得分:1)
应该是:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="timebar" type="id"/>
<item name="textClock" type="id"/>
</resources>
裁判是here。
答案 1 :(得分:1)
在资源文件上,删除结束标记和正文,即删除“ tv_deviceName”
<item type="id" name="button_ok">tv_deviceName</item>
Id应如下所示
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="button_ok" />
<item type="id" name="dialog_exit" />
</resources>
然后,此布局代码段使用Button小部件的“ button_ok” ID:
<Button android:id="@id/button_ok"
.... />
请注意,android:id值未在ID引用中包含加号,因为ID已存在(如上述ids.xml示例中所定义)。 (当您使用加号为android:id =“ @ + id / name”格式指定XML资源的ID时,这意味着“名称” ID不存在,应该创建。)
作为另一个示例,以下代码段使用“ dialog_exit” ID作为对话框的唯一标识符:
showDialog(R.id.dialog_exit);
引用:Click here.