InflateException происходит с использованием скользящих изображений загрузки - PullRequest
2 голосов
/ 19 июня 2019

InflateException возникает, когда большое количество изображений загружается с использованием glide.

Я провел некоторое исследование и понял, что InflateException может не быть реальной причиной сбоя моего приложения для Android, реальная проблема должна быть внеобъем памяти.Также я попытался добавить android: largeHeap = "true" в AndroidManifest.xml и использовать thumbnail () или override () меньшего размера при использованиискользить, чтобы загрузить изображения, но эти операции не решили проблему.

Кстати, мне кажется, что таких сообщений много, ни одно из этих изображений не требуется в xmls моего проекта внутри "res / drawble".

Обновление : Мне кажется, проблема в «decoderesource», но все же попытайтесь выяснить, где нужны эти изображения. Оказывается, есть флажок в каждом gridView, когда флажок удален, все работает нормально.Есть идеи, как это исправить?

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

А вот и исключение:

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)

Здесь загружаются изображения.

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);
    }

1 Ответ

0 голосов
/ 20 июня 2019

Я настроил стиль флажка, сообщение «decoderesource» больше не отображается и проблема нехватки памяти решена ...

...