简体   繁体   English

错误:找不到与给定名称匹配的资源(在'icon'处,值为'@ drawable / icon')

[英]Error : No resource found that matches the given name (at 'icon' with value '@drawable/icon')

Error : No resource found that matches the given name (at 'icon' with value '@drawable/icon'). 错误:找不到与给定名称匹配的资源(在'icon'处,值为'@ drawable / icon')。

This is my manifest... I'm extremely new to this, just started this morning and have no previous programming experience. 这是我的表现......我对此非常陌生,今天早上刚刚开始,没有以前的编程经验。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.asdf"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="19" />

 <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
 </application>
<application android:label="@string/app_name" android:icon="@drawable/icon">
<activity android:name="ExampleActivity"
          android:label="@string/app_name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
</application>

</manifest>

Found this question. 发现了这个问题。 I was importing an old project into android studio and got the error. 我正在将一个旧项目导入android studio并得到错误。

The issue was eventually answered for me here mipmap drawables for icons 这个问题最终在这里回答了mipmap drawables for icons

In the manifest it has 在它的清单中

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
...

but @drawable has been superseded by @mipmap so needed changing to: 但@drawable已被@mipmap取代,因此需要更改为:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
...

I put this answer here, as it may become a more common issue. 我把这个答案放在这里,因为它可能成为一个更常见的问题。

是什么解决了我的问题是 - 在“..platforms / android / res /”中创建一个文件夹“drawable”并在其中放入“icon.png”。

If you are 100% sure that directories and files are ok, have a look at the project location. 如果您100%确定目录和文件正常,请查看项目位置。

There is a limit on the path length of files in the Operating System. 操作系统中的文件路径长度有限制。 Perhaps this limit is being exceded in your project files. 也许这个限制在项目文件中被排除。

Move the project to a shorter folder (say C:/MyProject) and try again! 将项目移动到较短的文件夹(例如C:/ MyProject),然后重试!

This was the problem for me! 这对我来说是个问题!

I've spent on this problem much time and as for me ( for Intellij IDEA ) the solution is to specify right path to res directory : 我花了很多时间来处理这个问题,对于我( 对于Intellij IDEA ),解决方案是指定res目录的正确路径

  • right click on project 右键单击项目
  • click Modules in the left panel 单击左侧面板中的模块
  • select Android below your project name 在项目名称下方选择Android
  • in Structure tab set right path. 在Structure选项卡中设置右路径。

And don't forget to check all the paths in this tab ! 并且不要忘记检查此选项卡中的所有路径

I hope it will be helpful for somebody! 我希望它会对某人有所帮助!

Remove this line from your manifest: 从清单中删除此行:

<application android:label="@string/app_name" android:icon="@drawable/icon">

You have two application tags only one should be present. 您有两个应用程序标记,只有一个应该存在。

你需要通过visual添加icon.png

Resouces... / Dravable/ Add ///

Yet another Googlemare Landmine.... Somehow, if you mess up, the icon line on your .gen file dies. 另一个Googlemare Landmine ......不知何故,如果你陷入困境,.gen文件上的图标行就会消失。 (Empirical proof of mine after struggling 2 hours) (经过2小时奋斗后我的经验证明)

Insert a new icon 72x72 icon on the hdpi folder with a different name from the original, and update the name on the manifest also. 在hdpi文件夹上插入一个新图标72x72图标,其名称与原始名称不同,并同时更新清单上的名称。

The icon somehow resurrects on the Gen file and voila!! 图标以某种方式在Gen文件上复活并瞧!! time to move on. 分手后要往前看了。

This happens when you have previously changed your icon or the ic_launcher; 以前更改了图标或ic_launcher时会发生这种情况; and when that ic_launcher no longer exists in your base folder. 当你的基本文件夹中不再存在ic_launcher时

Try adding a png image and giving the same name and then copy it to your drawable folder.Now re build the project. 尝试添加一个png图像并给出相同的名称,然后将其复制到您的drawable文件夹。现在重新构建项目。

i had this problem. 我有这个问题。 i created a picture for my background with jpg format. 我用jpg格式为我的背景创建了一张图片。 before added this picture, i changed the format to png with rename the format. 在添加此图片之前,我将格式更改为png并重命名格式。 and then i got this error like you. 然后我得到了像你这样的错误。 i changed my format picture with picture editor like photoshop to png and replaced it with picture in my project and then i hadnt that error. 我用照片编辑器改变我的格式图片,如photoshop到png,用我的项目中的图片替换它,然后我没有错误。 sory for bad english 英国人不好的故事

if cordova app copy a valid png file to 如果cordova app将有效的png文件复制到

resources\\android\\icon.png 资源\\机器人\\的icon.png

and then run 然后跑

ionic resources --icon 离子资源 - 图标

In my case, I use Xamarin with Visual Studio 2013. I create Blank App (Android) then deploy without any code update. 就我而言,我在Visual Studio 2013中使用Xamarin。我创建了空白应用程序(Android),然后在没有任何代码更新的情况下进行部署。

You can try: 你可以试试:

  • Make sure that icon.png (or whatever files mentioned in the application android:icon tag) is present in the drawable-hdpi folder inside res folder of Android project. 确保icon.png(或应用程序android:icon标签中提到的任何文件)存在于Android项目res文件夹内的drawable-hdpi文件夹中。

  • If it shows the error even if the icon.png is present,then remove the statement application android:icon from the AndroidManifest.xml and add it again. 如果即使存在icon.png也显示错误,则从AndroidManifest.xml中删除语句应用程序android:icon并再次添加。

  • Check your project folder's path. 检查项目文件夹的路径。 If it is too long, or contains space, or contains any unicode character, try to relocated. 如果它太长,或包含空格,或包含任何unicode字符,请尝试重新定位。

Trying to build HelloWorld app on Ubuntu 16.04. 试图在Ubuntu 16.04上构建HelloWorld应用程序。 Got error with drawable/icon. drawable / icon出错。 Solution could be: 解决方案可能是:

cp ./platforms/android/build/intermediates/exploded-aar/com.android.support/design/25.3.1/res/drawable/navigation_empty_icon.xml    ./platforms/android/build/intermediates/exploded-aar/com.android.support/design/25.3.1/res/drawable/icon.xml

So, it look like icon.xml file missed. 所以,看起来像icon.xml文件错过了。

I also encountered this error. 我也遇到过这个错误。 I have a Cordova application and the problem was that in config.xml I had a duplicated element <icon src="icon.png"> , one pointing to an non-existing path. 我有一个Cordova应用程序,问题是在config.xml我有一个重复的元素<icon src="icon.png"> ,一个指向一个不存在的路径。

有一个更简单的解决方案 - 删除用户/ .android / built-cache中的缓存文件夹并返回到android studio并再次与gradle同步,如果仍然无法再次删除缓存文件夹,并重新启动android studio并重新启动 - 进口项目

暂无
暂无

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

相关问题 错误:在Cordova中找不到与给定名称(在&#39;icon&#39;处,值为&#39;@ drawable / icon&#39;)相匹配的资源 - Error: No resource found that matches the given name (at 'icon' with value '@drawable/icon') in Cordova cmd:命令失败,退出代码为1,错误:找不到与给定名称匹配的资源(在&#39;icon&#39;处,值为&#39;@ drawable / icon&#39;) - cmd: Command failed with exit code 1, Error : No resource found that matches the given name (at 'icon' with value '@drawable/icon') 错误:(16、23)找不到与给定名称匹配的资源(在“ icon”处,值为“ @ drawable / icon”) - Error:(16, 23) No resource found that matches the given name (at 'icon' with value '@drawable/icon') Unity项目中的错误:找不到与给定名称匹配的资源(在“ icon”处,值为“ @ drawable / ic_launcher”) - Error in Unity project : No resource found that matches the given name (at 'icon' with value '@drawable/ic_launcher') 错误:找不到与给定名称匹配的资源(在“ icon”处,值为“ @ drawable / ic_launcher”) - Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_launcher') 错误的XML块,错误:找不到与给定名称匹配的资源(在&#39;icon&#39;处,值为&#39;@android:drawable - Bad XML block, Error: No resource found that matches the given name (at 'icon' with value '@android:drawable 错误:找不到与给定名称匹配的资源(在“ icon”处,值为“ @ drawable / ic_launcher”) - Error: No resource found that matches the given name (at 'icon' with value '@drawable/ ic_launcher') 找不到与给定名称匹配的资源(在“ icon”处具有值…) - No resource found that matches the given name (at 'icon' with value …) “找不到与给定名称匹配的资源(在带有值的‘图标’处”) - "No resource found that matches the given name (at 'icon' with value" 找不到与给定名称匹配的资源(在“ icon”处,值为“ @ drawable / ic_launcher”) - No resource found that matches the given name (at 'icon' with value '@drawable/ic_launcher')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM