简体   繁体   English

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

[英]Android Studio - No resource found that matches the given name

I am developing an app in Android Studio, I used the Android Asset Studio to make the launcher icon, and then I tried to Copy/Paste the new icon to overwrite the default one (like I always did in Eclipse) and nothing happens, so what I did was changing the name of the default ic_launcher to a.png and then from the windows eplorer copy/paste each ic_launcher.png in the corresponding mipmap folder, and delete de a.png 's files (while Android Studio was running) and then that error was shown. 我正在Android Studio中开发一个应用程序,我使用Android Asset Studio制作了启动器图标,然后尝试复制/粘贴新图标以覆盖默认图标(就像我在Eclipse中一样),因此没有任何反应,因此我所做的是将默认ic_launcher的名称更改为a.png ,然后从Windows eplorer复制/粘贴了相应的mipmap文件夹中的每个ic_launcher.png ,并删除了a.png的文件(在Android Studio运行时)然后显示该错误。

I tried clean, rebuild, build , refresh, resync the project and nothing happens, I am getting the same error. 我尝试清理,重建,构建,刷新,重新同步项目,但没有任何反应,我遇到了相同的错误。 I also try to rename the build folder to build.old as this thread says, but still the error. 正如线程所说,我也尝试将构建文件夹重命名为build.old,但仍然是错误。

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\21.1.2\aapt.exe'' finished with non-zero exit value 1

Manifest.xml 的Manifest.xml

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

Also I tried to change the value of android:icon="@mipmap/a.png" to android:icon="@mipmap/ic_launcher.png" but every time I rebuild it changes again to a.png . 我也尝试将android:icon="@mipmap/a.png"的值更改为android:icon="@mipmap/ic_launcher.png"但每次重建时,它都会再次更改为a.png

Would I have to start from 0 and make a new project and copy all the things I have done or there is a way to fix this? 我是否必须从0开始创建一个新项目并复制我所做的所有事情,或者有办法解决这个问题?

The solution that worked for me: 对我有用的解决方案:

I deleted the mipmap folder in android studio and clicked right on res folder -> new -> Image asset, then image selection -> next ..... 我在android studio中删除了mipmap文件夹,然后在res文件夹上单击鼠标右键->新建->图像资产,然后选择图像->下一个.....

You do not specify the .png 您未指定.png

Just do: 做就是了:

android:icon="@mipmap/a"

So, anything worked and I had to remake the app and copy/paste all clases and activities: 因此,一切正常,我不得不重新制作该应用程序并复制/粘贴所有分类和活动:

Lesson: Do not mess up with the project files from the explorer, go for the automatic, frameworked solutions that Android Studio gives to you. 课程:不要搞乱资源管理器中的项目文件,请使用Android Studio提供给您的自动框架化解决方案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android Studio:未找到与给定名称匹配的资源:attr&#39;android:actionModeShareDrawable&#39; - Android Studio : No resource found that matches the given name: attr 'android:actionModeShareDrawable' Android错误:找不到与Android Studio中的给定名称匹配的资源 - Android Error: No resource found that matches the given name in Android Studio 问题Android Studio找不到与给定名称匹配的资源 - Problems Android studio No resource found that matches the given name 错误未找到与给定名称匹配的资源:Android Studio中的attr&#39;borderWidth&#39; - Error No resource found that matches the given name: attr 'borderWidth' in Android Studio 字体android studio 3错误:找不到与给定名称匹配的资源 - Error with fonts android studio 3: No resource found that matches the given name Android Studio - 错误:找不到与给定名称匹配的资源:attr&#39;metaButtonBarButtonStyle&#39; - Android Studio - Error: No resource found that matches the given name: attr 'metaButtonBarButtonStyle' Android Studio:找不到与给定名称匹配的资源:attr&#39;searchViewTextField&#39; - Android Studio: No resource found that matches the given name: attr 'searchViewTextField' 找不到与给定名称Android匹配的资源 - No resource found that matches the given name Android 找不到与给定名称Xamarin Android匹配的资源 - No Resource found that matches the given name Xamarin Android 找不到与给定名称Android 1.6匹配的资源 - no resource found that matches the given name Android 1.6
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM