gpt4 book ai didi

java.lang.OutOfMemoryError : Failed to allocate a allocation until OOM 错误

转载 作者:太空狗 更新时间:2023-10-29 15:35:45 26 4
gpt4 key购买 nike

实际上,我正在尝试创建一个包含 n 个多媒体文件(包括图像和视频)的应用程序。我的应用程序大小约为 34MB,我的 Assets 大小约为 60mb。当我在普通设备上加载应用程序时,我们没有遇到任何问题,但是具有 2K 分辨率 的设备,例如 Nexus 6P、HTC、LG 等,应用程序得到在进程中间崩溃并出现错误“内存不足”。我已经用这个生成了错误报告。我也尝试过位图工厂。同时我在数组方法中使用视频。

谁能帮忙解决这个问题?

FATAL EXCEPTION: main Process: com.example.we.appname, PID: 9353

java.lang.OutOfMemoryError: Failed to allocate a 1660396 byte allocation with 1243880 free bytes and 1214KB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:620) at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:455) at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1155) at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:720) at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:571) at android.content.res.Resources.loadDrawable(Resources.java:858) at android.content.res.TypedArray.getDrawable(TypedArray.java:928) at android.graphics.drawable.AnimationDrawable.inflateChildElements(AnimationDrawable.java:327) at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:297) at android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.java:130) at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1227) at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1200) at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:715) at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:571) at android.content.res.Resources.getDrawable(Resources.java:771) at android.content.Context.getDrawable(Context.java:525) at android.view.View.setBackgroundResource(View.java:18228) at com.example.kq.meettheshps.Score_Card.onCreate(Score_Card.java:58) at android.app.Activity.performCreate(Activity.java:6679) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

最佳答案

我发现的简单解决方案是,在application AndroidManifest.xml

下添加 hardwareAccelerated & largeHeap
<application
android:allowBackup="true"
android:hardwareAccelerated="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">

关于java.lang.OutOfMemoryError : Failed to allocate a allocation until OOM 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41184166/

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