Ошибка выхода из памяти при смене фона и изображений в макетах? - PullRequest
0 голосов
/ 17 апреля 2019

Я разрабатываю свое приложение впервые, и в папке для рисования у меня есть фоновое изображение с разрешением 1080 * 2560 и размером 200 КБ, а также некоторые значки, которые я устанавливаю в режиме просмотра изображений с разрешением 500 * 500 и от 12 КБ до 15 КБ. в размерах и в формате PNG.

Когда я устанавливаю их в макете моего приложения, я получаю исключение из памяти, так как есть несколько действий, и установка этих рисований дает мне ошибку OOM в каждом действии при изменении дизайна.

Также стоит упомянуть, что после внесения изменений в фоновые изображения и изображения я проверил 3–4 устройства Android и все работает нормально, но на 2 устройствах выдает ошибку OOM.

это ошибка

/AndroidRuntime: FATAL EXCEPTION: main
Process: com.intrusoft.sectionedrecyclerviewapp, PID: 22558
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.intrusoft.sectionedrecyclerviewapp/com.intrusoft.sectionedrecyclerviewapp.StartActivity}: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class <unknown>
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3254)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)
    at android.app.ActivityThread.access$1100(ActivityThread.java:222)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:7237)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
 Caused by: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class <unknown>
    at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
    at com.intrusoft.sectionedrecyclerviewapp.StartActivity.onCreate(StartActivity.java:42)
    at android.app.Activity.performCreate(Activity.java:6876)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350) 
    at android.app.ActivityThread.access$1100(ActivityThread.java:222) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:158) 
    at android.app.ActivityThread.main(ActivityThread.java:7237) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
 Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class <unknown>
    at android.view.LayoutInflater.createView(LayoutInflater.java:657)
    at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:706)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:774)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
    at com.intrusoft.sectionedrecyclerviewapp.StartActivity.onCreate(StartActivity.java:42) 
    at android.app.Activity.performCreate(Activity.java:6876) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350) 
    at android.app.ActivityThread.access$1100(ActivityThread.java:222) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:158) 
    at android.app.ActivityThread.main(ActivityThread.java:7237) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
 Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.newInstance(Native Method)
    at android.view.LayoutInflater.createView(LayoutInflater.java:631)
    at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:706) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:774) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:847) 
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:527) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
    at com.intrusoft.sectionedrecyclerviewapp.StartActivity.onCreate(StartActivity.java:42) 
    at android.app.Activity.performCreate(Activity.java:6876) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350) 
    at android.app.ActivityThread.access$1100(ActivityThread.java:222) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:158) 
    at android.app.ActivityThread.main(ActivityThread.java:7237) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
 Caused by: java.lang.OutOfMemoryError: Failed to allocate a 101606412 byte allocation with 16765280 free bytes and 59MB until OOM
    at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
    at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:856)
    at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:675)
    at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:2228)
    at android.content.res.Resources.loadDrawableForCookie(Resources.java:4215)
    at android.content.res.Resources.loadDrawable(Resources.java:4089)
    at android.content.res.Resources.loadDrawable(Resources.java:3939)
    at android.content.res.TypedArray.getDrawable(TypedArray.java:886)
    at android.view.View.<init>(View.java:4230)
    at android.view.ViewGroup.<init>(ViewGroup.java:589)
    at android.widget.LinearLayout.<init>(LinearLayout.java:202)
    at android.widget.LinearLayout.<init>(LinearLayout.java:198)
...