drawable/ic_launcher_foreground not found. How to find that xml file

Thr*_*ddy 10 android android-layout android-drawable

Gradle build is not successful because it cannot find ic_launcher_foreground.xml in drawable.

以下是错误信息

此文件中发生实际错误

Blu*_*ell 15

我遇到了问题并且文件确实存在。

我进入文件并格式化内容(也就是进行了更改),并修复了识别文件的构建系统。

  • 在我用头撞墙 30 分钟并多次重新创建资产之后,**这**为我解决了这个问题。打开“现有”前台 xml,在标签末尾按 Enter 键,然后重建。现在正在发挥作用。疯子!! (2认同)

小智 10

如果您从 android 项目中删除了ic_launcher_foreground.xmlic_launcher_background.xml文件,则无需担心。简单地,

  1. 右键单击 drawable 目录(在 res 文件夹内)并选择 New ---> Image Asset。(上面的2个命名文件会用ic_laucher自动生成)
  2. 然后点击下一步,最后完成。

  • 我正在尝试执行此操作,但由于某种原因,“image asset”工具没有创建“ic_launcher_foreground.xml”文件 - 其他所有内容看起来都已就位。我使用实际图像来创建图标 - 并在“前景”选项卡“资产类型路径”中选择该图像的路径。当我单击“下一步”时,会显示要创建的所有输出目录/文件 - “ic_launcher_foreground.xml”文件未在任何地方列出,仅“drawable/ic_launcher_background.xml”、“mipmap-anydpi-v26/ic_launcher.xml” ` 和 `mipmap-anydpi-v26/ic_launcher_round.xml` (2认同)

Aks*_*iya 7

It is because you have accidentally deleted ic_launcher_forground or it is missing due to some reason

它通常存在于您的可绘制文件夹中
在此处输入图片说明

一个快速的解决方法是你可以添加这个文件并再次重建你的项目ic_launcher_forground

  • 感谢您投反对票 带有简短解释的评论将非常有帮助... (2认同)

小智 5

我通过删除项目的 Mipmap 文件夹并通过右键单击 res / 文件夹再次创建图标来解决它

  • 为我工作。虽然说明可能更清楚:单击右键单击 res 文件夹 > 新建 > 图像资源后 (6认同)