Android Studio - 找不到与给定名称匹配的资源

Android Studio - No resource found that matches the given name

我正在 Android Studio 中开发应用程序,我使用 Android Asset Studio 制作启动器图标,然后我尝试 Copy/Paste 新图标覆盖默认一个(就像我在 Eclipse 中一直做的那样)但没有任何反应,所以我所做的是将默认 ic_launcher 的名称更改为 a.png,然后从 windows eplorer copy/paste 每个 ic_launcher.png 在相应的 mipmap 文件夹中,并删除 de a.png 的文件(而 Android Studio 是 运行)然后显示该错误。

我尝试了清理、重建、构建、刷新、重新同步项目,但没有任何反应,我遇到了同样的错误。我也尝试将构建文件夹重命名为 build.old 正如 this 线程所说,但仍然是错误。

Error:(16, 23) No resource found that matches the given name (at 'icon' with value '@mipmap/a.png').
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\MyUser\AppData\Local\Android\Sdk\build-tools.1.2\aapt.exe'' finished with non-zero exit value 1

Manifest.xml

 ...<application
        android:allowBackup="true"
        android:icon="@mipmap/a.png"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity ...

我也尝试将 android:icon="@mipmap/a.png" 的值更改为 android:icon="@mipmap/ic_launcher.png" 但每次重建时它都会再次更改为 a.png.

我是否必须从 0 开始并创建一个新项目并复制我所做的所有事情,或者有办法解决这个问题?

您没有指定.png

就这样:

android:icon="@mipmap/a"

所以,一切正常,我不得不重新制作应用程序和 copy/paste 所有课程和活动:

教训:不要弄乱资源管理器中的项目文件,使用 Android Studio 为您提供的自动框架解决方案。

对我有用的解决方案:

我删除了android studio中的mipmap文件夹,右击res文件夹->新建->图像资源,然后选择图像->下一步.....