Recyclerview + Picasso outofmemory错误

时间:2016-06-03 10:39:55

标签: android android-recyclerview picasso

使用recyclerview和picasso时,我面临着outofmemory的问题。

Picasso.with(context).load(waterSourcesList.get(position).icon).into(holder.ivSourceIcon);

当屏幕主页连续移动到第二个屏幕和第二个屏幕到主屏幕时,我收到以下错误:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xyz.android/com.xyz.android.second.SecondActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2201)
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
                                                                            at android.app.ActivityThread.access$900(ActivityThread.java:141)
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1213)
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                            at android.os.Looper.loop(Looper.java:136)
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5072)
                                                                            at java.lang.reflect.Method.invokeNative(Native Method)
                                                                            at java.lang.reflect.Method.invoke(Method.java:515)
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
                                                                            at dalvik.system.NativeStart.main(Native Method)
                                                                         Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
                                                                            at android.view.LayoutInflater.createView(LayoutInflater.java:623)
                                                                            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
                                                                            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:672)
                                                                            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:472)
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:400)
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
                                                                            at com.madzialipo.android.boreholeNearMe.SecondActivity.onCreate(SecondActivity.java:70)
                                                                            at android.app.Activity.performCreate(Activity.java:5249)
                                                                            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2165)
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250) 
                                                                            at android.app.ActivityThread.access$900(ActivityThread.java:141) 
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1213) 
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                            at android.os.Looper.loop(Looper.java:136) 
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5072) 
                                                                            at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                            at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) 
                                                                            at dalvik.system.NativeStart.main(Native Method) 
                                                                         Caused by: java.lang.reflect.InvocationTargetException
                                                                            at java.lang.reflect.Constructor.constructNative(Native Method)
                                                                            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
                                                                            at android.view.LayoutInflater.createView(LayoutInflater.java:597)
                                                                            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
                                                                            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:672) 
                                                                            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697) 
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:472) 
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:400) 
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
                                                                            at com.madzialipo.android.boreholeNearMe.SecondActivity.onCreate(SecondActivity.java:70) 
                                                                            at android.app.Activity.performCreate(Activity.java:5249) 
                                                                            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2165) 
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250) 
                                                                            at android.app.ActivityThread.access$900(ActivityThread.java:141) 
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1213) 
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                            at android.os.Looper.loop(Looper.java:136) 
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5072) 
                                                                            at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                            at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) 
                                                                            at dalvik.system.NativeStart.main(Native Method) 
                                                                         Caused by: java.lang.OutOfMemoryError
                                                                            at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
                                                                            at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:601)
                                                                            at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:434)
                                                                            at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
                                                                            at android.content.res.Resources.createFromResourceStream(Resources.java:2513)
                                                                            at android.content.res.Resources.loadDrawable(Resources.java:2165)
                                                                            at android.content.res.Resources.loadDrawable(Resources.java:2072)
                                                                            at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
                                                                            at android.view.View.<init>(View.java:3562)
                                                                            at android.view.ViewGroup.<init>(ViewGroup.java:470)
                                                                            at android.widget.LinearLayout.<init>(LinearLayout.java:176)
                                                                            at android.widget.LinearLayout.<init>(LinearLayout.java:172)
                                                                            at java.lang.reflect.Constructor.constructNative(Native Method) 
                                                                            at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
                                                                            at android.view.LayoutInflater.createView(LayoutInflater.java:597) 
                                                                            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
                                                                            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:672) 
                                                                            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697) 
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:472) 
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:400) 
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
                                                                            at com.madzialipo.android.boreholeNearMe.SecondActivity.onCreate(SecondActivity.java:70) 
                                                                            at android.app.Activity.performCreate(Activity.java:5249) 
                                                                            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2165) 
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250) 
                                                                            at android.app.ActivityThread.access$900(ActivityThread.java:141) 
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1213) 
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                            at android.os.Looper.loop(Looper.java:136) 
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5072) 
                                                                            at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                            at java.lang.reflect.Method.invoke(Method.java:515)

1 个答案:

答案 0 :(得分:0)

这件事发生在我身上,因为我从我的同事那里得到了他在背景中使用重型图像的项目。所以,应用程序崩溃了。我刚删除了背景图片及其完成。