![](/img/trans.png)
[英]Error: No resource found that matches the given name (at 'icon' with value '@drawable/icon') in Cordova
[英]Error : No resource found that matches the given name (at 'icon' with value '@drawable/icon')
錯誤:找不到與給定名稱匹配的資源(在'icon'處,值為'@ drawable / icon')。
這是我的表現......我對此非常陌生,今天早上剛剛開始,沒有以前的編程經驗。
<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>
發現了這個問題。 我正在將一個舊項目導入android studio並得到錯誤。
這個問題最終在這里回答了mipmap drawables for icons
在它的清單中
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
...
但@drawable已被@mipmap取代,因此需要更改為:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
...
我把這個答案放在這里,因為它可能成為一個更常見的問題。
是什么解決了我的問題是 - 在“..platforms / android / res /”中創建一個文件夾“drawable”並在其中放入“icon.png”。
如果您100%確定目錄和文件正常,請查看項目位置。
操作系統中的文件路徑長度有限制。 也許這個限制在項目文件中被排除。
將項目移動到較短的文件夾(例如C:/ MyProject),然后重試!
這對我來說是個問題!
我花了很多時間來處理這個問題,對於我( 對於Intellij IDEA ),解決方案是指定res目錄的正確路徑 :
並且不要忘記檢查此選項卡中的所有路徑 !
我希望它會對某人有所幫助!
從清單中刪除此行:
<application android:label="@string/app_name" android:icon="@drawable/icon">
您有兩個應用程序標記,只有一個應該存在。
你需要通過visual添加icon.png 。
Resouces... / Dravable/ Add ///
另一個Googlemare Landmine ......不知何故,如果你陷入困境,.gen文件上的圖標行就會消失。 (經過2小時奮斗后我的經驗證明)
在hdpi文件夾上插入一個新圖標72x72圖標,其名稱與原始名稱不同,並同時更新清單上的名稱。
圖標以某種方式在Gen文件上復活並瞧!! 分手后要往前看了。
以前更改了圖標或ic_launcher時會發生這種情況; 當你的基本文件夾中不再存在ic_launcher時
嘗試添加一個png圖像並給出相同的名稱,然后將其復制到您的drawable文件夾。現在重新構建項目。
我有這個問題。 我用jpg格式為我的背景創建了一張圖片。 在添加此圖片之前,我將格式更改為png並重命名格式。 然后我得到了像你這樣的錯誤。 我用照片編輯器改變我的格式圖片,如photoshop到png,用我的項目中的圖片替換它,然后我沒有錯誤。 英國人不好的故事
如果cordova app將有效的png文件復制到
資源\\機器人\\的icon.png
然后跑
離子資源 - 圖標
就我而言,我在Visual Studio 2013中使用Xamarin。我創建了空白應用程序(Android),然后在沒有任何代碼更新的情況下進行部署。
你可以試試:
確保icon.png(或應用程序android:icon標簽中提到的任何文件)存在於Android項目res文件夾內的drawable-hdpi文件夾中。
如果即使存在icon.png也顯示錯誤,則從AndroidManifest.xml中刪除語句應用程序android:icon並再次添加。
檢查項目文件夾的路徑。 如果它太長,或包含空格,或包含任何unicode字符,請嘗試重新定位。
試圖在Ubuntu 16.04上構建HelloWorld應用程序。 drawable / icon出錯。 解決方案可能是:
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
所以,看起來像icon.xml文件錯過了。
我也遇到過這個錯誤。 我有一個Cordova應用程序,問題是在config.xml
我有一個重復的元素<icon src="icon.png">
,一個指向一個不存在的路徑。
有一個更簡單的解決方案 - 刪除用戶/ .android / built-cache中的緩存文件夾並返回到android studio並再次與gradle同步,如果仍然無法再次刪除緩存文件夾,並重新啟動android studio並重新啟動 - 進口項目
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.