当前位置 : 主页 > 手机开发 > android >

Android – 内部元素必须是资源引用或空

来源:互联网 收集:自由互联 发布时间:2021-06-11
错误详情 AGPBI: {"kind":"error","text":"error: inner element must either be a resource reference or empty.","sources":[{"file":"...\\app\\src\\main\\res\\values\\ids.xml","position":{"startLine":2,"startColumn":4,"startOffset":57,"endCo
错误详情

AGPBI: {"kind":"error","text":"error: 
  

  
   
  inner element must either be a resource reference or empty.","sources":[{"file":"...\\app\\src\\main\\res\\values\\ids.xml","position":{"startLine":2,"startColumn":4,"startOffset":57,"endColumn":61,"endOffset":114}}],"original":"","tool":"AAPT"} :app:mergeDebugResources Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details :app:mergeDebugResources FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:mergeDebugResources'. > Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details. 

  

资源文件

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="tv_deviceName" type="id">tv_deviceName</item>
</resources>

建立环境

> Android Studio 3.1.4
> minSdkVersion = 21
> targetSdkVersion = 28
> compileSdkVersion = 28
> buildToolsVersion =“28.0.2”

在资源中声明id时,正文应为空

<item
    type="id"
    name="id_name" />

欲了解更多信息,请查看以下链接

https://developer.android.com/guide/topics/resources/more-resources#Id

正如Oliver Manyasa所说,它应该如下所示

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="tv_deviceName" type="id"/>
</resources>
网友评论