在我的android项目中:内部元素必须是资源引用或为空

时间:2019-03-19 18:18:45

标签: android-studio-3.0

Android Studio 3.2.1

在我的build.gradle中:

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.myproject"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

在我的res \ values \ ids.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <item type="id" name="tokenEntryLogo">false</item>
    <item type="id" name="action0">false</item>
    <item type="id" name="cancel_action">false</item>
    <item type="id" name="status_bar_latest_event_content">false</item>
    <item type="id" name="media_actions">false</item>
</resources>

但我收到错误消息:

> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources FAILED
> Task :app:buildInfoGeneratorDebug

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
  app\src\main\res\values\ids.xml:192:5-48: AAPT: error: <item> inner element must either be a resource reference or empty.

  app\src\main\res\values\ids.xml:229:5-51: AAPT: error: <item> inner element must either be a resource reference or empty.

  \app\src\main\res\values\ids.xml:46:5-51: AAPT: error: <item> inner element must either be a resource reference or empty.

1 个答案:

答案 0 :(得分:0)

找到您的 ids.xml 文件,并进行如下修改。

之前:

<item name="back_btn" type="id">false</item>

之后:

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

提示 您可以使用“ sublime”之类的任何编辑器。

然后,
查找:>false</item>
替换:/>
全部完成!