1

InflateException happens when large count of images are loaded using glide.

I've done some research and realized InflateException may not be the actual reason my android application crashes, the real issue should be out-of-memory. Also I've tried to add android:largeHeap="true" to AndroidManifest.xml & use thumbnail() or override() a smaller size when using glide to load images, but these operations didn't solve the problem.

By the way I've seem lots of messages like this, none of these images are needed in my project's xmls inside "res/drawble".

Update: I think "decoderesource" is the problem, but still try to figure out where these images are needed. Turns out there is a checkbox in every gridView, when the checkbox is deleted, everything works fine. Any idea how to fix this?

V/BitmapFactory: DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/btn_check_to_on_mtrl_015.png
V/BitmapFactory: DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/btn_check_to_on_mtrl_000.png
    DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/btn_check_to_on_mtrl_015.png
V/BitmapFactory: DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/btn_check_to_on_mtrl_000.png
    DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/btn_check_to_on_mtrl_000.png
V/BitmapFactory: DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/btn_check_to_on_mtrl_001.png
    DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/btn_check_to_on_mtrl_002.png
    DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/btn_check_to_on_mtrl_003.png
    DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/btn_check_to_on_mtrl_004.png
    DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/btn_check_to_on_mtrl_005.png
    DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/btn_check_to_on_mtrl_006.png
V/BitmapFactory: DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/btn_check_to_on_mtrl_007.png

And here is the exception:

E/art: Throwing OutOfMemoryError "Failed to allocate a 36876 byte allocation with 5238 free bytes and 5KB until OOM"
D/skia: --- decoder->decode returned false
D/AndroidRuntime: Shutting down VM
I/art: Alloc sticky concurrent mark sweep GC freed 23(1648B) AllocSpace objects, 0(0B) LOS objects, 0% free, 127MB/128MB, paused 2.803ms total 25.861ms
I/art: Clamp target GC heap from 143MB to 128MB
    Alloc partial concurrent mark sweep GC freed 136(22KB) AllocSpace objects, 12(432KB) LOS objects, 0% free, 127MB/128MB, paused 918us total 59.735ms
I/art: Alloc sticky concurrent mark sweep GC freed 5421(265KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 127MB/128MB, paused 1.248ms total 14.342ms
I/art: Clamp target GC heap from 142MB to 128MB
    Alloc partial concurrent mark sweep GC freed 5484(269KB) AllocSpace objects, 36(1296KB) LOS objects, 1% free, 126MB/128MB, paused 906us total 54.921ms
I/art: Alloc sticky concurrent mark sweep GC freed 31817(1543KB) AllocSpace objects, 0(0B) LOS objects, 1% free, 126MB/128MB, paused 758us total 12.917ms
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.winzip.android, PID: 9988
    android.view.InflateException: Binary XML file line #19: Error inflating class <unknown>
        at android.view.LayoutInflater.createView(LayoutInflater.java:640)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
        at com.winzip.android.commonadapter.ViewHolder.get(ViewHolder.java:44)
        at com.winzip.android.commonadapter.MultiItemTypeAdapter.getView(MultiItemTypeAdapter.java:60)
        at android.widget.AbsListView.obtainView(AbsListView.java:2825)
        at android.widget.GridView.makeAndAddView(GridView.java:1437)
        at android.widget.GridView.makeRow(GridView.java:361)
        at android.widget.GridView.fillDown(GridView.java:302)
        at android.widget.GridView.fillFromTop(GridView.java:437)
        at android.widget.GridView.layoutChildren(GridView.java:1280)
        at android.widget.AbsListView.onLayout(AbsListView.java:2629)
        at android.view.View.layout(View.java:16678)
        at android.view.ViewGroup.layout(ViewGroup.java:5328)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1465)
        at android.view.View.layout(View.java:16678)
        at android.view.ViewGroup.layout(ViewGroup.java:5328)
        at android.widget.ListView.setupChild(ListView.java:1980)
        at android.widget.ListView.makeAndAddView(ListView.java:1889)
        at android.widget.ListView.fillDown(ListView.java:713)
        at android.widget.ListView.fillFromTop(ListView.java:779)
        at android.widget.ListView.layoutChildren(ListView.java:1693)
        at android.widget.AbsListView.onLayout(AbsListView.java:2629)
        at android.view.View.layout(View.java:16678)
        at android.view.ViewGroup.layout(ViewGroup.java:5328)
        at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1077)
        at android.view.View.layout(View.java:16678)
        at android.view.ViewGroup.layout(ViewGroup.java:5328)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
        at android.view.View.layout(View.java:16678)
        at android.view.ViewGroup.layout(ViewGroup.java:5328)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1465)
        at android.view.View.layout(View.java:16678)
        at android.view.ViewGroup.layout(ViewGroup.java:5328)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
        at android.view.View.layout(View.java:16678)
        at android.view.ViewGroup.layout(ViewGroup.java:5328)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1465)
        at android.view.View.layout(View.java:16678)
        at android.view.ViewGroup.layout(ViewGroup.java:5328)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
        at android.view.View.layout(View.java:16678)
        at android.view.ViewGroup.layout(ViewGroup.java:5328)
        at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2319)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2032)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1191)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6643)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
        at android.view.Choreographer.doCallbacks(Choreographer.java:590)
        at android.view.Choreographer.doFrame(Choreographer.java:560)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
        at android.os.Handler.handleCallback(Handler.java:739)

This is where images are loaded.

protected void convert(final ViewHolder viewHolder, final ScanImgModel item, final int position) {
        if (item.isBest())
            viewHolder.setVisible(R.id.ac_clean_detail_repeat_best, true);
        ImageView imageView = (ImageView) viewHolder.getView(R.id.ac_clean_detail_repeat_image);
        viewHolder.setChecked(R.id.ac_clean_detail_item_checkbox, item.isSelected());
        Glide.with(mContext)
                .load(item.getPath())
                .into(imageView);
    }
z xx
  • 11
  • 2
  • how are you getting the image path ? - getpath() method code needs to be checked – PJain Jun 19 '19 at 13:19
  • Actually when images' count reaches a certain amount, even if I don't load any of them into imageView, the exception also exists. Thank you for your reply. – z xx Jun 20 '19 at 02:01

1 Answers1

0

I've custom the style of checkbox, the "decoderesource" message no longer shows and out-of-memory problem solved...

z xx
  • 11
  • 2