2014-03-31 69 views
0

我製作的HangMan遊戲是隨機的200個活動,每個活動都有動畫,但是我不知道如何清除水平之後的動畫,波紋管在我的Google Developer Console中出錯,任何人都知道如何解決這個問題?如何防止Android編碼中的OutOfMemoryError

java.lang.OutOfMemoryError 
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596) 
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444) 
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:832) 
at android.content.res.Resources.loadDrawable(Resources.java:2988) 
at android.content.res.Resources.getDrawable(Resources.java:1558) 
at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:282) 
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:937) 
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:873) 
at android.content.res.Resources.loadDrawable(Resources.java:2970) 
at android.content.res.Resources.getDrawable(Resources.java:1558) 
at android.view.View.setBackgroundResource(View.java:15697) 
at kids.game.hangmanforkids.crab.update_HangMan_Picture(crab.java:913) 
at kids.game.hangmanforkids.crab$13.onClick(crab.java:615) 
at android.view.View.performClick(View.java:4475) 
at android.view.View$PerformClick.run(View.java:18786) 
at android.os.Handler.handleCallback(Handler.java:730) 
at android.os.Handler.dispatchMessage(Handler.java:92) 
at android.os.Looper.loop(Looper.java:176) 
at android.app.ActivityThread.main(ActivityThread.java:5419) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:525) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) 
at dalvik.system.NativeStart.main(Native Method) 
+0

你並行運行的線程? –

+0

親愛的Naveen Kuma,那位先生你是什麼意思? – user3208987

+0

這意味着你在發生錯誤時運行任何parralel執行.. –

回答

1

嘗試機器人:largeHeap = 「真」增加堆大小爲您menifest您的應用程序。一些設備具有固定數量的應用程序使用的內存,例如每個應用程序64 MB。或者使用縮放和緩存來修復使用我的應用程序的內存。 已經看這些鏈接 http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html

How to increase heap size of an android application?

+0

@ user3208987你可以upvote我的答案? –