2011-10-05 43 views
6

我開始從市場崩潰報告界面看到一組奇怪的堆棧跟蹤。我被告知可繪製資源不存在。存在問題的XML:

<ImageView 
    android:layout_width="13dip" 
    android:layout_height="12dip" 
    android:src="@drawable/foo" 
    /> 

造成:

java.lang.RuntimeException: 
    Unable to start activity ComponentInfo{com.me.app/com.me.app.MyActivity}: 
    android.view.InflateException: Binary XML file line #51: 
    Error inflating class <unknown> 
... 
Caused by: android.content.res.Resources$NotFoundException: 
    File res/drawable-hdpi/foo.png from drawable resource ID #0x7f020166 
    at android.content.res.Resources.loadDrawable(Resources.java:1732) 
    at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 
    at android.widget.ImageView.<init>(ImageView.java:118) 
    at android.widget.ImageView.<init>(ImageView.java:108) 
Caused by: java.io.FileNotFoundException: 
    res/drawable-hdpi/foo.png 
    at android.content.res.AssetManager.openNonAssetNative(Native Method) 
    at android.content.res.AssetManager.openNonAsset(AssetManager.java:417) 
    at android.content.res.Resources.loadDrawable(Resources.java:1724) 

現在 「foo.png」 同時存在於我的 「繪製」 和 「繪製 - 華電國際」 的文件夾。我很久沒有觸及這些可繪製的任何一個 - 不知道爲什麼這個錯誤開始出現?通過放置在foo.png其他可繪製文件夾即MDPI,xhdpi和xxhdpi也發生在一個範圍的裝置,機器人,納克斯問鼎的等

由於

+0

也許你應該清理你的項目來重新生成R.java文件?這可能是問題。 – Egor

+0

嗨,Egor,我肯定是在我上次發佈前做過這個。我檢查了R文件,整數值都存在。我認爲android有問題。 – user291701

+0

這真的讓我感到困擾。我注意到我的新編譯的應用程序遇到了這些問題。我開始認爲我應該使用assets文件夾編寫我自己的系統。然後我可以有一個很好的層次來配合它。我也注意到Lint不正確地標記錯誤。 –

回答

0

你可以嘗試以下方法:

1 - 如果你在Eclipse中開發,從調試菜單中嘗試「清潔工程」。如果您在Intellij中,請嘗試「構建」該項目。

2-刪除並讀取foo.png資源。刪除後,嘗試重新生成R然後讀取。

3將foo.png重命名爲其他內容並查看它是如何工作的。

4-嘗試刪除R檔,因爲它可以讓自動生成的,可以解決你的問題

據我所知,這個問題是你的項目的R檔。

相關問題