1

I get a crash report on the Google Play Console on this device: Samsung Galaxy A5(2016) (a5xelte),

java.lang.OutOfMemoryError: 

  at dalvik.system.VMRuntime.newNonMovableArray (Native Method)

  at android.graphics.BitmapFactory.nativeDecodeAsset (Native Method)

  at android.graphics.BitmapFactory.decodeStream (BitmapFactory.java:700)

  at android.graphics.BitmapFactory.decodeResourceStream (BitmapFactory.java:535)

  at android.graphics.drawable.Drawable.createFromResourceStream (Drawable.java:1179)

  at android.content.res.ResourcesImpl.loadDrawableForCookie (ResourcesImpl.java:770)

  at android.content.res.ResourcesImpl.loadDrawable (ResourcesImpl.java:621)

  at android.content.res.Resources.loadDrawable (Resources.java:1729)

  at android.content.res.TypedArray.getDrawable (TypedArray.java:945)

  at android.widget.ImageView.<init> (ImageView.java:157)

  at android.widget.ImageView.<init> (ImageView.java:145)

  at android.support.v7.widget.AppCompatImageView.<init> (AppCompatImageView.java:60)

  at android.support.v7.widget.AppCompatImageView.<init> (AppCompatImageView.java:56)

  at android.support.v7.internal.app.AppCompatViewInflater.createView (AppCompatViewInflater.java:98)

  at android.support.v7.app.AppCompatDelegateImplV7.createView (AppCompatDelegateImplV7.java:926)

  at android.support.v7.app.AppCompatDelegateImplV7.onCreateView (AppCompatDelegateImplV7.java:980)

  at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView (LayoutInflaterCompatHC.java:44)

  at android.view.LayoutInflater$FactoryMerger.onCreateView (LayoutInflater.java:193)

  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:776)

  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:734)

  at android.view.LayoutInflater.rInflate (LayoutInflater.java:865)

  at android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:828)

  at android.view.LayoutInflater.rInflate (LayoutInflater.java:873)

  at android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:828)

  at android.view.LayoutInflater.rInflate (LayoutInflater.java:873)

  at android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:828)

  at android.view.LayoutInflater.rInflate (LayoutInflater.java:873)

  at android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:828)

  at android.view.LayoutInflater.inflate (LayoutInflater.java:525)

  at android.view.LayoutInflater.inflate (LayoutInflater.java:427)

  at package.Accueil.onCreateView (Accueil.java:75)

  at android.support.v4.app.Fragment.performCreateView (Fragment.java:1965)

  at android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1078)

  at android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1259)

  at android.support.v4.app.BackStackRecord.run (BackStackRecord.java:738)

  at android.support.v4.app.FragmentManagerImpl.execPendingActions (FragmentManager.java:1624)

  at android.support.v4.app.FragmentController.execPendingActions (FragmentController.java:330)

  at android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java:547)

  at android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1256)

  at android.app.Activity.performStart (Activity.java:6972)

  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2937)

  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3045)

  at android.app.ActivityThread.-wrap14 (ActivityThread.java)

  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1642)

  at android.os.Handler.dispatchMessage (Handler.java:102)

  at android.os.Looper.loop (Looper.java:154)

  at android.app.ActivityThread.main (ActivityThread.java:6776)

  at java.lang.reflect.Method.invoke (Native Method)

  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1496)

  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1386)

The crash line : at package.Accueil.onCreateView (Accueil.java:75)

Is this one:

TextView textView = (TextView) getActivity().findViewById(R.id.main_toolbar_title);

I don't understand how the app can crash on this line. I did search on Google they talk about big file to load...

Here is all of my drawables:

enter image description here

The view:

enter image description here

I think the problem is with my drawables and the density of the images, I don't rteally understand this: I did a question about:

Understanding Drawables and Images sizes

I don't know if I have all screen sizes.

6
  • have u set any bg image in text view in xml? Commented Feb 8, 2018 at 13:11
  • OutOfMemoryError is not possible with this line of code . Double check your production code and confirm the line number . Commented Feb 8, 2018 at 13:16
  • @duggu I have many images on this activity and big size images too Commented Feb 8, 2018 at 13:19
  • then this is main problem Commented Feb 8, 2018 at 13:20
  • @ADM Ok Google Play Console showed this line (75) and the line is the TextView, how to know where it crashes Commented Feb 8, 2018 at 13:20

3 Answers 3

1

OOME comes while instantiating your layout (especially images) - maybe there is some bad bitmap which is too big? Maybe your layout is too complex?

Sign up to request clarification or add additional context in comments.

8 Comments

Why the error is on this devices ? Can I simulate it with a virtual device ? I have many images, this is the image size or the weight ?
Could be a lot of cauese - device has less memory than others, device uses one version of resource (because of screen resolution or whatever )which is buggy..... As for simulating on virtual device - it willl be difficult to recreate particular phone. Maybe you can get real one and debug?
So I can't know where it came from ? Can I do something ? Like pass images on tinypng to compress images ?
It is definitely some image. Hard to telll which. DO you have dieeferent assets for different resolutions etc?
Impossible to tell what exact cause is.
|
1

OOM is not usually related to one place. Even though the crash is at at package.Accueil.onCreateView (Accueil.java:75) most likely it's not caused by that. IN my experience the OOM are caused by bigger images than needed.

If you are downloading images from some server use Glide to fetch it because it will keep in memory only the resized image that fits your view even if the actual image was way bigger before resize. Check this comparison between Glide and Picasso: https://inthecheesefactory.com/blog/get-to-know-glide-recommended-by-google/en

You might also check for memory leaks using LeakCanary but I would first start with images.

1 Comment

Okay so I did an edit with the view, I don't have a lot of big images on, but I think the problem is with the drawables..
0

Your problem is when this line is executed, the platform creates your View heirarchy. You presumably have lots of big images in your view, so your App has to allocate a lot of memory to display all these big images. So now the solution comes down to how do you fix things. You have two options:

  • Have a design with fewer or smaller images
  • Make your images use less memory

I'd advise doing both. I can't advise you on improving the design. But for reducing sizes, this section in the documentation is a good guide. It is talking about network transfer, but will probably help in your APK too.

There is also some good advice here.

1 Comment

Okay so I did an edit with the view, I don't have a lot of big images on, but I think the problem is with the drawables..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.