Build unsuccessful after updating android studio to 3.0. Error:Found unexpected optical bounds (red pixel)

Build unsuccessful after updating android studio to 3.0. Error:Found unexpected optical bounds (red pixel)

我在 Ubuntu 中将我的 Android Studio 更新到了 3.0。当我加载一个项目时,它无法构建,而同一个项目在 Android Studio 的先前版本 (v2.3) 中构建时也没有问题。错误说,

Error:found unexpected optical bounds (red pixel) on top border at x=14.

Error:.

Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error

更新到 Android Studio 3.0 后,我也遇到了同样的问题。我通过设置 android.enableAapt2=false

解决了这个问题

Improved incremental resource processing using AAPT2, which is enabled by default. If you are experiencing issues while using AAPT2, you can disable it by setting android.enableAapt2=false in your gradle.properties file and restarting the Gradle daemon by running ./gradlew --stop from the command line.

更多信息请见here

终于找到问题所在了。这是由于我在项目资源中使用了大约 9 个补丁图标。我使用了一些第 3 方工具来绘制这些图标。现在,我将这些图标替换为使用 Android studio(see how) 生成的相同图标,一切正常。

另外,如果您不想使用 AAPT2。您可以按照@capt.swag

的建议,通过在 gradle.properties 文件中设置 android.enableAapt2=false 来禁用