为什么Android Studio无法构建,图像上出现AAPT2错误? [英] Why is Android Studio failing to build, with an AAPT2 error on images?

查看:230
本文介绍了为什么Android Studio无法构建,图像上出现AAPT2错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近一次更新后,Android Studio无法构建未修改的项目,并且出现以下几行错误:

After a recent update, Android Studio fails to build an unmodified project with errors along these lines:

> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade

  > AAPT2 aapt2-4.1.1-6503028-linux Daemon #0: Unexpected error during compile '/path/to/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png', attempting to stop daemon.
    This should not happen under normal circumstances, please file an issue if it does.

请注意,它在Android Studio本身提供的图像上失败!

Notice that it's failing on an image supplied by Android Studio itself!

该如何解决?

推荐答案

当涉及到PNG图片时,这似乎是最新(较新?)Gradle插件中的错误;Google的IssueTracker沿这些路线列出了几个新报告的错误.其中一个提到这是Gradle问题;我通过恢复到以前的版本来完成我的工作:Gradle Plugin 4.0.1和Gradle 6.1.1版可以正常工作.

This seems to be an error in the newest (newer?) Gradle plugin(s) when it comes to PNG images; Google's IssueTracker lists several newly reported bugs along these lines. One of them mentions that it's a Gradle issue; I made mine work by reverting to a previous version: Gradle Plugin 4.0.1 and Gradle version 6.1.1 work fine.

在解决此问题之前,有必要忽略AS对新版本的na.

It will be necessary to ignore AS' nagging about a newer version until this gets fixed.

[应@YinOrYan的要求添加]

要恢复到较早版本的Gradle,请执行以下操作:

To revert to an older version of Gradle:

  1. 在菜单中,选择文件",然后选择项目结构..."
  2. 在弹出的对话框中,选择项目"(我版本中的第一项).
  3. 您可以从下拉菜单中选择所需的Gradle插件和Gradle版本.

这不应丢失任何系统调用,因为这与SDK或API版本不同.但是,它们不是独立,因此设置它们的位置可能受到限制.

This should not lose any system calls, as this is different from the SDK or API versions. However, it's not independent of them, so there is probably a limit to where you can set them.

与往常一样,当您首次构建或需要导入依赖项时,您将希望在线,但否则应该可以脱机工作.

As usual you will want to be online when you first build, or whenever you have to import a dependency, but otherwise it should be possible to work offline.

这篇关于为什么Android Studio无法构建,图像上出现AAPT2错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆