實際上,我嘗試創建一個包含n個包含圖像和視頻的多媒體文件的應用程序。我的應用程序大小約爲34MB
,我的資產大小約爲60mb
。當我在普通設備中加載應用程序時,我們沒有遇到任何問題,但是具有2K resolutions
(例如Nexus 6P, HTC, LG
等)的設備,應用程序在進程中間出現「內存不足」錯誤。 我用這個產生了錯誤報告。我也試圖位圖工廠。 同時我在數組方法中使用視頻。java.lang.OutOfMemoryError:在OOM之前無法分配分配
任何人都可以幫助解決這個問題嗎?
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)
你必須根據scren大小有效地加載你的位圖..看到這個https://developer.android.com/training/displaying-bitmaps/load-bitmap.html – rafsanahmad007