2012-02-27 35 views
1
故障處理PNG圖像

我在res/drawable文件夾中保存我的圖像,但它仍然是給我的控制檯錯誤:在Android的

[2012-04-28 18:36:46 - Local] libpng error: Not a PNG file 
[2012-04-28 18:36:46 - Local] ERROR: Failure processing PNG image D:\Android2_worksapce\Local\res\drawable-ldpi\ic_launcher.png 
[2012-04-28 18:36:46 - Local] libpng error: Not a PNG file 
[2012-04-28 18:36:46 - Local] ERROR: Failure processing PNG image D:\Android2_worksapce\Local\res\drawable-mdpi\ic_launcher.png 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\aboutus.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/about'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\autofare.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/auto'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\busroutes.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/bus'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\busroutes.xml:63: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/right'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\busroutes.xml:72: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/cancel'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\firstscreenactivity.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/mumbai1'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\listviewofwesternavailabletrains.xml:8: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/cell3'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\main.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/first'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\mumbaihelpline.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/helpline'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\selectambulance.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/ambu'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\selectedwesterntraindetails.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/list6'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\selecthospital.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/hospital'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\selectservicelistview.xml:7: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/cell1'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\selecttrainline.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/curv'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\taxifare.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/taxi'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\westernavailabletrains.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/list5'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\westernavailabletrains.xml:18: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/cell3'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\youareatcentral.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/local'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\youareatcentral.xml:70: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/right'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\youareatcentral.xml:79: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/cancel'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\youareatharbour.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/local'). 
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\youareatharbour.xml:69: error: Error: No resource found that matches the given name (at 'background' with value '@drawable/right'). 

我已保存的圖像(PNG格式)的資源此錯誤,但它給我一個錯誤,說明它不是PNG文件。誰能幫我嗎?

+1

將圖像上傳到某處。我認爲該圖像不是一個PNG文件或損壞。 – rekire 2012-02-27 13:41:16

+0

我已經將文件保存在PNG格式 – Rahul 2012-02-27 13:44:42

+0

它是res/drawable不是資源/可繪製的(請參閱您的問題的第1行)。 – Stefan 2012-02-27 13:45:59

回答

6

一個簡單但耗時的解決方案... 嘗試在mspaint中打開您的PNG,並保存爲。這個問題將解決.. 我不知道爲什麼我們需要做..但不知何故,它的工作對我來說...

2

檢查this鏈接,參考

的Android不支持24位和32位, 但它有一些問題與ADOBE PHOTOSHOP的PNG文件。 所以解決方案是在MS Paint中打開並再次保存,如Kalpesh Patel所說。

希望這可以幫助你

1

這是因爲任何JPG文件中被錯誤地轉換爲png文件。如果您在可繪製文件夾(資源文件夾)中添加了任何圖像,請確保所有圖像擴展名應爲png,表示不要將擴展名jpg更改爲png。如果你想將JPG轉換爲PNG,那麼使用在線工具或編輯器進行轉換。

問題是如果圖像沒有正確轉換爲PNG,那麼當你運行的時候會出現這個錯誤。

解決方案:第1步是否最近在可繪製文件夾中添加了任何圖像?如果是的話,檢查所有的圖像擴展應該是適當的(我的意思是不強制添加PNG擴展)。

第二,如果你不知道哪個圖像擴展是不妥當的,那麼你應該有編輯在編輯器或在線工具的所有PNG圖像並再次保存成PNG文件,這個問題將得到解決的當然。

我花了3個小時對此進行了解,我想出了這個解決方案。這是我的錯誤,我編輯JPG圖像PNG,但它沒有正確轉換爲PNG,所以這就是爲什麼它給了我錯誤。當我選擇該圖像並正確轉換爲PNG文件後,它對我有用!