Android 错误:找不到与给定名称匹配的资源(在值为 '@drawable/icon' 的 'icon' 处)!
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23796761/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error : No resource found that matches the given name (at 'icon' with value '@drawable/icon')!
提问by PositivityRiven
Error : No resource found that matches the given name (at 'icon' with value '@drawable/icon').
错误:找不到与给定名称匹配的资源(在值为“@drawable/icon”的“icon”处)。
This is my manifest... I'm extremely new to this, just started this morning and have no previous programming experience. Also, extremely sorry for post code formatting, i'm really bad at this.
这是我的清单......我对此非常陌生,今天早上刚开始,以前没有编程经验。另外,对于邮政编码格式非常抱歉,我真的很糟糕。
<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>
回答by ILovemyPoncho
you have two applicationtags in your manifest. get rid of this part:
您的清单中有两个应用程序标签。去掉这部分:
</application>
<application android:label="@string/app_name" android:icon="@drawable/icon">
After that. If you are trying to use your own icon, put your icon in the drawable folder, and replace:
在那之后。如果您尝试使用自己的图标,请将您的图标放在 drawable 文件夹中,然后替换:
android:icon="@drawable/ic_launcher"
with:
和:
android:icon="@drawable/your_icon"
回答by Josh
Yet another Googlemare Landmine.... Somehow, if you mess up, the icon line on your .gen file dies. (Empirical proof of mine after struggling 2 hours)
又一个 Googlemare Landmine ......不知何故,如果你搞砸了,你的 .gen 文件上的图标行就会消失。(我挣扎了 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!! time to move on.
图标不知何故在 Gen 文件上复活了,瞧!!分手后要往前看了。
回答by Ashkan Safaiepour
first time I Creates my app in one of my drives that have bitLocker. but second time I creates that in my system drive(c).and now every thing is ok. I fix it :) you can do this...
我第一次在我的一个具有 bitLocker 的驱动器中创建我的应用程序。但是第二次我在我的系统驱动器(c)中创建了它。现在一切正常。我修好了:)你可以这样做......
回答by ajinkya
<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/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<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>
Make sure you put your icon.png
in drawable folders.
确保你把你的icon.png
放在 drawable 文件夹中。
(96x96 in xhdpi, 72x72 in hdpi, 48x48 in mdpi)
(xhdpi 为 96x96,hdpi 为 72x72,mdpi 为 48x48)