gpt4 book ai didi

java - InflateException 使用滑行加载图像时发生

转载 作者:行者123 更新时间:2023-11-30 12:05:03 26 4
gpt4 key购买 nike

InflateException 在使用 glide 加载大量图像时发生。

我做了一些研究并意识到 InflateException 可能不是我的 android 应用程序崩溃的真正原因,真正的问题应该是内存不足。我还尝试将 android:largeHeap="true" 添加到 AndroidManifest.xml 并使用 thumbnail()override() 一个更小的使用glide加载图片时的大小,但是这些操作都没有解决问题。

顺便说一句,我已经看到很多这样的消息,在我的项目的“res/drawble”内的 xml 中不需要这些图像。

更新:我认为“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

这里是异常(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)

这是加载图像的地方。

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

最佳答案

我自定义了复选框的样式,“decoderesource”消息不再显示,内存不足的问题也解决了...

关于java - InflateException 使用滑行加载图像时发生,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56668580/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com