2012-11-19 186 views
0

我得到這個例外時不時,它的相當煩人我。在我的應用程序,我們只是掃描一個條形碼,它將數據從條形碼發送到server.I已經嘗試了很多事情來清理內存和以避免內存泄漏,但似乎沒有任何工作。任何幫助將appriciated。內存不足異常

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.zxing.client.android/com.example.mypackage.filename}: android.view.InflateException: Binary XML file line #12: Error inflating class at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1652) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668) 
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2852) 
at android.app.ActivityThread.access$1600(ActivityThread.java:117) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:940) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:123) 
at android.app.ActivityThread.main(ActivityThread.java:3703) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class 
at android.view.LayoutInflater.createView(LayoutInflater.java:518) 
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:408) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:212) 
at android.app.Activity.setContentView(Activity.java:1657) 
at com.example.mypackage.filename.onCreate(TaskSelector.java:164) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1616) 
... 12 more Caused by: java.lang.reflect.InvocationTargetException 
at java.lang.reflect.Constructor.constructNative(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:415) 
at android.view.LayoutInflater.createView(LayoutInflater.java:505) 
... 23 more Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget 
at android.graphics.Bitmap.nativeCreate(Native Method) at android.graphics.Bitmap.createBitmap(Bitmap.java:477) 
at android.graphics.Bitmap.createBitmap(Bitmap.java:444) 
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:349) 
at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:498) 
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:473) 
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336) 
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697) 
at android.content.res.Resources.loadDrawable(Resources.java:1709) 
at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 
at android.view.View.(View.java:1951) at android.view.View.(View.java:1899) 
at android.view.ViewGroup.(ViewGroup.java:286) at android.widget.RelativeLayout.(RelativeLayout.java:173) ... 26 more 
+0

你可以發佈一些代碼嗎? –

+0

你的XML文件已損壞? – Bevor

+0

有一件事是,Android的活動通常是可取的,直到80視圖,所以如果你可以刪除一些,在第二個注意事項嘗試增加你的IDE的內存,你可能會使用eclipse,並請張貼你認爲你的代碼的一部分可能會導致問題 –

回答

0

您的位圖太大,或者一次加載太多。

+0

我使用了很多有圖像的按鈕。他們是罪魁禍首嗎? – Payal

+1

只要圖像尺寸適當,這應該沒問題。如果他們全都是400x400而你有10個,那麼他們太大了。查看關於ldpi,mdpi,hdpi和xhdpi的指導,並根據需要以適當的大小創建足夠的圖像。 http://developer.android.com/guide/practices/screens_support.html – cjk

+0

謝謝,但我使用42X55左右的小尺寸。但會嘗試調整它們的大小。 – Payal

1
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

使用此代碼,這可能是有益還是讓我知道我有其他的解決方案,甚至