在 Android Studio 中更改项目 "buildToolsVersion" 时出错

Error on changing "buildToolsVersion" of project in Android Studio

我使用 Android Studio 3.1.4android gradle plugin version 3.1.4

之前我在模块的build.gradle里设置了buildToolsVersion "27.0.3",在building/running里没有问题。今天我安装了更新版本的 build tools 并更改 build.gradle 以使用它:buildToolsVersion "28.0.2"

但是当我尝试 sync project with gradle filesrebuild project 时,它以 AAPT2 错误结束:

AGPBI: {"kind":"error","text":"error: \u003citem\u003e inner element must either be a resource reference or empty.","sources":[{"file":"<path to module>/src/main/res/values/ids.xml","position":{"startLine":16,"startColumn":4,"startOffset":752,"endColumn":55,"endOffset":803}}],"original":"","tool":"AAPT"}
....
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':<modulee-name>:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details

但我不明白是什么原因导致的错误。例如,错误的地址行是:

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

是什么原因导致此错误以及如何解决此问题?

编辑

我将 android.enableAapt2=false 添加到 gradle.properties 并且它似乎忽略了错误,但会导致此警告:

The option 'android.enableAapt2' is deprecated and should not be used anymore. Use 'android.enableAapt2=true' to remove this warning. It will be removed at the end of 2018..

您不能将 false(也不能是任何其他值,但它是 name)分配给 ID resource

An ID is a simple resource that is referenced using the value provided in the name attribute (not the name of the XML file). As such, you can combine ID resources with other simple resources in the one XML file, under one element. Also, remember that an ID resources does not reference an actual resource item; it is simply a unique ID that you can attach to other resources or use as a unique integer in your application.

with android.enableAapt2=false 它可能会忽略逻辑错误,但不会 "fix it".