android - galaxy s4 and maybe all HD phones? out of memory error inflating layout -
so app working on, works fine on old miserable android 2.3.3 phone. when running on gs4, gs4 throwing out of memory exceptions every time has load resource drawables, predefined in xml.
<imageview android:id="@+id/ivlearnmore" android:layout_width="match_parent" android:layout_height="200dp" android:layout_weight="1" android:scaletype="fitcenter" android:src="@drawable/learn_more" />
for example imageview throw exception when inflating layout because has image assigned. (256x256)
what going on?
05-08 10:33:54.972: e/dalvikvm-heap(24423): out of memory on 16777232-byte allocation. 05-08 10:33:54.972: i/dalvikvm(24423): "main" prio=5 tid=1 runnable 05-08 10:33:54.972: i/dalvikvm(24423): | group="main" scount=0 dscount=0 obj=0x41187b38 self=0x40dd1b68 05-08 10:33:54.972: i/dalvikvm(24423): | systid=24423 nice=0 sched=0/0 cgrp=apps handle=1074533852 05-08 10:33:54.972: i/dalvikvm(24423): | state=r schedstat=( 0 0 0 ) utm=147 stm=1265 core=0 05-08 10:33:54.972: i/dalvikvm(24423): @ android.graphics.bitmapfactory.nativedecodeasset(native method) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:596) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.graphics.bitmapfactory.decoderesourcestream(bitmapfactory.java:444) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.graphics.drawable.drawable.createfromresourcestream(drawable.java:817) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.content.res.resources.loaddrawable(resources.java:2854) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.content.res.typedarray.getdrawable(typedarray.java:602) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.view.view.<init>(view.java:3460) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.view.viewgroup.<init>(viewgroup.java:446) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.widget.linearlayout.<init>(linearlayout.java:176) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.widget.linearlayout.<init>(linearlayout.java:172) 05-08 10:33:54.972: i/dalvikvm(24423): @ java.lang.reflect.constructor.constructnative(native method) 05-08 10:33:54.972: i/dalvikvm(24423): @ java.lang.reflect.constructor.newinstance(constructor.java:417) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.view.layoutinflater.createview(layoutinflater.java:593) 05-08 10:33:54.972: i/dalvikvm(24423): @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:56) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.view.layoutinflater.oncreateview(layoutinflater.java:666) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:691) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.view.layoutinflater.inflate(layoutinflater.java:467) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.view.layoutinflater.inflate(layoutinflater.java:397) 05-08 10:33:54.972: i/dalvikvm(24423): @ com.travelstorysgps.travelstorys.fragmentinfo.oncreateview(fragmentinfo.java:54) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.support.v4.app.fragment.performcreateview(fragment.java:1460) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:911) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1088) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.support.v4.app.backstackrecord.run(backstackrecord.java:682) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1444) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.support.v4.app.fragmentmanagerimpl$1.run(fragmentmanager.java:429) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.os.handler.handlecallback(handler.java:725) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.os.handler.dispatchmessage(handler.java:92) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.os.looper.loop(looper.java:137) 05-08 10:33:54.972: i/dalvikvm(24423): @ android.app.activitythread.main(activitythread.java:5293) 05-08 10:33:54.972: i/dalvikvm(24423): @ java.lang.reflect.method.invokenative(native method) 05-08 10:33:54.972: i/dalvikvm(24423): @ java.lang.reflect.method.invoke(method.java:511) 05-08 10:33:54.972: i/dalvikvm(24423): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1102) 05-08 10:33:54.972: i/dalvikvm(24423): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:869) 05-08 10:33:54.972: i/dalvikvm(24423): @ dalvik.system.nativestart.main(native method) 05-08 10:33:54.972: d/skia(24423): --- decoder->decode returned false 05-08 10:33:54.972: d/androidruntime(24423): shutting down vm 05-08 10:33:54.972: w/dalvikvm(24423): threadid=1: thread exiting uncaught exception (group=0x41186ac8) 05-08 10:33:54.992: e/androidruntime(24423): fatal exception: main 05-08 10:33:54.992: e/androidruntime(24423): android.view.inflateexception: binary xml file line #2: error inflating class <unknown> 05-08 10:33:54.992: e/androidruntime(24423): @ android.view.layoutinflater.createview(layoutinflater.java:619) 05-08 10:33:54.992: e/androidruntime(24423): @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:56) 05-08 10:33:54.992: e/androidruntime(24423): @ android.view.layoutinflater.oncreateview(layoutinflater.java:666) 05-08 10:33:54.992: e/androidruntime(24423): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:691) 05-08 10:33:54.992: e/androidruntime(24423): @ android.view.layoutinflater.inflate(layoutinflater.java:467) 05-08 10:33:54.992: e/androidruntime(24423): @ android.view.layoutinflater.inflate(layoutinflater.java:397) 05-08 10:33:54.992: e/androidruntime(24423): @ com.travelstorysgps.travelstorys.fragmentinfo.oncreateview(fragmentinfo.java:54) 05-08 10:33:54.992: e/androidruntime(24423): @ android.support.v4.app.fragment.performcreateview(fragment.java:1460) 05-08 10:33:54.992: e/androidruntime(24423): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:911) 05-08 10:33:54.992: e/androidruntime(24423): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1088) 05-08 10:33:54.992: e/androidruntime(24423): @ android.support.v4.app.backstackrecord.run(backstackrecord.java:682) 05-08 10:33:54.992: e/androidruntime(24423): @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1444) 05-08 10:33:54.992: e/androidruntime(24423): @ android.support.v4.app.fragmentmanagerimpl$1.run(fragmentmanager.java:429) 05-08 10:33:54.992: e/androidruntime(24423): @ android.os.handler.handlecallback(handler.java:725) 05-08 10:33:54.992: e/androidruntime(24423): @ android.os.handler.dispatchmessage(handler.java:92) 05-08 10:33:54.992: e/androidruntime(24423): @ android.os.looper.loop(looper.java:137) 05-08 10:33:54.992: e/androidruntime(24423): @ android.app.activitythread.main(activitythread.java:5293) 05-08 10:33:54.992: e/androidruntime(24423): @ java.lang.reflect.method.invokenative(native method) 05-08 10:33:54.992: e/androidruntime(24423): @ java.lang.reflect.method.invoke(method.java:511) 05-08 10:33:54.992: e/androidruntime(24423): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1102) 05-08 10:33:54.992: e/androidruntime(24423): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:869) 05-08 10:33:54.992: e/androidruntime(24423): @ dalvik.system.nativestart.main(native method) 05-08 10:33:54.992: e/androidruntime(24423): caused by: java.lang.reflect.invocationtargetexception 05-08 10:33:54.992: e/androidruntime(24423): @ java.lang.reflect.constructor.constructnative(native method) 05-08 10:33:54.992: e/androidruntime(24423): @ java.lang.reflect.constructor.newinstance(constructor.java:417) 05-08 10:33:54.992: e/androidruntime(24423): @ android.view.layoutinflater.createview(layoutinflater.java:593) 05-08 10:33:54.992: e/androidruntime(24423): ... 21 more 05-08 10:33:54.992: e/androidruntime(24423): caused by: java.lang.outofmemoryerror 05-08 10:33:54.992: e/androidruntime(24423): @ android.graphics.bitmapfactory.nativedecodeasset(native method) 05-08 10:33:54.992: e/androidruntime(24423): @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:596) 05-08 10:33:54.992: e/androidruntime(24423): @ android.graphics.bitmapfactory.decoderesourcestream(bitmapfactory.java:444) 05-08 10:33:54.992: e/androidruntime(24423): @ android.graphics.drawable.drawable.createfromresourcestream(drawable.java:817) 05-08 10:33:54.992: e/androidruntime(24423): @ android.content.res.resources.loaddrawable(resources.java:2854) 05-08 10:33:54.992: e/androidruntime(24423): @ android.content.res.typedarray.getdrawable(typedarray.java:602) 05-08 10:33:54.992: e/androidruntime(24423): @ android.view.view.<init>(view.java:3460) 05-08 10:33:54.992: e/androidruntime(24423): @ android.view.viewgroup.<init>(viewgroup.java:446) 05-08 10:33:54.992: e/androidruntime(24423): @ android.widget.linearlayout.<init>(linearlayout.java:176) 05-08 10:33:54.992: e/androidruntime(24423): @ android.widget.linearlayout.<init>(linearlayout.java:172) 05-08 10:33:54.992: e/androidruntime(24423): ... 24 more
here exception different screen
05-08 10:35:29.565: e/dalvikvm-heap(24774): out of memory on 16777232-byte allocation. 05-08 10:35:29.565: i/dalvikvm(24774): "main" prio=5 tid=1 runnable 05-08 10:35:29.565: i/dalvikvm(24774): | group="main" scount=0 dscount=0 obj=0x41187b38 self=0x40dd1b68 05-08 10:35:29.565: i/dalvikvm(24774): | systid=24774 nice=0 sched=0/0 cgrp=apps handle=1074533852 05-08 10:35:29.565: i/dalvikvm(24774): | state=r schedstat=( 0 0 0 ) utm=175 stm=2086 core=1 05-08 10:35:29.565: i/dalvikvm(24774): @ android.graphics.bitmapfactory.nativedecodeasset(native method) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:596) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.graphics.bitmapfactory.decoderesourcestream(bitmapfactory.java:444) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.graphics.drawable.drawable.createfromresourcestream(drawable.java:817) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.content.res.resources.loaddrawable(resources.java:2854) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.content.res.typedarray.getdrawable(typedarray.java:602) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.view.view.<init>(view.java:3460) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.view.viewgroup.<init>(viewgroup.java:446) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.widget.linearlayout.<init>(linearlayout.java:176) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.widget.linearlayout.<init>(linearlayout.java:172) 05-08 10:35:29.565: i/dalvikvm(24774): @ java.lang.reflect.constructor.constructnative(native method) 05-08 10:35:29.565: i/dalvikvm(24774): @ java.lang.reflect.constructor.newinstance(constructor.java:417) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.view.layoutinflater.createview(layoutinflater.java:593) 05-08 10:35:29.565: i/dalvikvm(24774): @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:56) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.view.layoutinflater.oncreateview(layoutinflater.java:666) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:691) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.view.layoutinflater.inflate(layoutinflater.java:467) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.view.layoutinflater.inflate(layoutinflater.java:397) 05-08 10:35:29.565: i/dalvikvm(24774): @ com.travelstorysgps.travelstorys.fragmentdonate.oncreateview(fragmentdonate.java:53) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.support.v4.app.fragment.performcreateview(fragment.java:1460) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:911) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1088) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.support.v4.app.backstackrecord.run(backstackrecord.java:682) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1444) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.support.v4.app.fragmentmanagerimpl$1.run(fragmentmanager.java:429) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.os.handler.handlecallback(handler.java:725) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.os.handler.dispatchmessage(handler.java:92) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.os.looper.loop(looper.java:137) 05-08 10:35:29.565: i/dalvikvm(24774): @ android.app.activitythread.main(activitythread.java:5293) 05-08 10:35:29.565: i/dalvikvm(24774): @ java.lang.reflect.method.invokenative(native method) 05-08 10:35:29.565: i/dalvikvm(24774): @ java.lang.reflect.method.invoke(method.java:511) 05-08 10:35:29.565: i/dalvikvm(24774): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1102) 05-08 10:35:29.565: i/dalvikvm(24774): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:869) 05-08 10:35:29.565: i/dalvikvm(24774): @ dalvik.system.nativestart.main(native method) 05-08 10:35:29.565: d/abslistview(24774): [unregisterdoubletapmotionlistener] 05-08 10:35:29.565: i/motionrecognitionmanager(24774): .unregisterlistener : / listener count = 0->0, 05-08 10:35:29.565: d/skia(24774): --- decoder->decode returned false 05-08 10:35:29.565: d/abslistview(24774): unregisterirlistener() called 05-08 10:35:29.565: d/androidruntime(24774): shutting down vm 05-08 10:35:29.565: w/dalvikvm(24774): threadid=1: thread exiting uncaught exception (group=0x41186ac8) 05-08 10:35:29.595: e/androidruntime(24774): fatal exception: main 05-08 10:35:29.595: e/androidruntime(24774): android.view.inflateexception: binary xml file line #2: error inflating class <unknown> 05-08 10:35:29.595: e/androidruntime(24774): @ android.view.layoutinflater.createview(layoutinflater.java:619) 05-08 10:35:29.595: e/androidruntime(24774): @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:56) 05-08 10:35:29.595: e/androidruntime(24774): @ android.view.layoutinflater.oncreateview(layoutinflater.java:666) 05-08 10:35:29.595: e/androidruntime(24774): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:691) 05-08 10:35:29.595: e/androidruntime(24774): @ android.view.layoutinflater.inflate(layoutinflater.java:467) 05-08 10:35:29.595: e/androidruntime(24774): @ android.view.layoutinflater.inflate(layoutinflater.java:397) 05-08 10:35:29.595: e/androidruntime(24774): @ com.travelstorysgps.travelstorys.fragmentdonate.oncreateview(fragmentdonate.java:53) 05-08 10:35:29.595: e/androidruntime(24774): @ android.support.v4.app.fragment.performcreateview(fragment.java:1460) 05-08 10:35:29.595: e/androidruntime(24774): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:911) 05-08 10:35:29.595: e/androidruntime(24774): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1088) 05-08 10:35:29.595: e/androidruntime(24774): @ android.support.v4.app.backstackrecord.run(backstackrecord.java:682) 05-08 10:35:29.595: e/androidruntime(24774): @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1444) 05-08 10:35:29.595: e/androidruntime(24774): @ android.support.v4.app.fragmentmanagerimpl$1.run(fragmentmanager.java:429) 05-08 10:35:29.595: e/androidruntime(24774): @ android.os.handler.handlecallback(handler.java:725) 05-08 10:35:29.595: e/androidruntime(24774): @ android.os.handler.dispatchmessage(handler.java:92) 05-08 10:35:29.595: e/androidruntime(24774): @ android.os.looper.loop(looper.java:137) 05-08 10:35:29.595: e/androidruntime(24774): @ android.app.activitythread.main(activitythread.java:5293) 05-08 10:35:29.595: e/androidruntime(24774): @ java.lang.reflect.method.invokenative(native method) 05-08 10:35:29.595: e/androidruntime(24774): @ java.lang.reflect.method.invoke(method.java:511) 05-08 10:35:29.595: e/androidruntime(24774): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1102) 05-08 10:35:29.595: e/androidruntime(24774): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:869) 05-08 10:35:29.595: e/androidruntime(24774): @ dalvik.system.nativestart.main(native method) 05-08 10:35:29.595: e/androidruntime(24774): caused by: java.lang.reflect.invocationtargetexception 05-08 10:35:29.595: e/androidruntime(24774): @ java.lang.reflect.constructor.constructnative(native method) 05-08 10:35:29.595: e/androidruntime(24774): @ java.lang.reflect.constructor.newinstance(constructor.java:417) 05-08 10:35:29.595: e/androidruntime(24774): @ android.view.layoutinflater.createview(layoutinflater.java:593) 05-08 10:35:29.595: e/androidruntime(24774): ... 21 more 05-08 10:35:29.595: e/androidruntime(24774): caused by: java.lang.outofmemoryerror 05-08 10:35:29.595: e/androidruntime(24774): @ android.graphics.bitmapfactory.nativedecodeasset(native method) 05-08 10:35:29.595: e/androidruntime(24774): @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:596) 05-08 10:35:29.595: e/androidruntime(24774): @ android.graphics.bitmapfactory.decoderesourcestream(bitmapfactory.java:444) 05-08 10:35:29.595: e/androidruntime(24774): @ android.graphics.drawable.drawable.createfromresourcestream(drawable.java:817) 05-08 10:35:29.595: e/androidruntime(24774): @ android.content.res.resources.loaddrawable(resources.java:2854) 05-08 10:35:29.595: e/androidruntime(24774): @ android.content.res.typedarray.getdrawable(typedarray.java:602) 05-08 10:35:29.595: e/androidruntime(24774): @ android.view.view.<init>(view.java:3460) 05-08 10:35:29.595: e/androidruntime(24774): @ android.view.viewgroup.<init>(viewgroup.java:446) 05-08 10:35:29.595: e/androidruntime(24774): @ android.widget.linearlayout.<init>(linearlayout.java:176) 05-08 10:35:29.595: e/androidruntime(24774): @ android.widget.linearlayout.<init>(linearlayout.java:172) 05-08 10:35:29.595: e/androidruntime(24774): ... 24 more
and here 3rd , different screen
05-08 10:37:20.113: e/dalvikvm-heap(25740): out of memory on 16777232-byte allocation. 05-08 10:37:20.123: i/dalvikvm(25740): "main" prio=5 tid=1 runnable 05-08 10:37:20.123: i/dalvikvm(25740): | group="main" scount=0 dscount=0 obj=0x41187b38 self=0x40dd1b68 05-08 10:37:20.123: i/dalvikvm(25740): | systid=25740 nice=0 sched=0/0 cgrp=apps handle=1074533852 05-08 10:37:20.123: i/dalvikvm(25740): | state=r schedstat=( 0 0 0 ) utm=156 stm=1070 core=1 05-08 10:37:20.123: i/dalvikvm(25740): @ android.graphics.bitmapfactory.nativedecodeasset(native method) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:596) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.graphics.bitmapfactory.decoderesourcestream(bitmapfactory.java:444) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.graphics.drawable.drawable.createfromresourcestream(drawable.java:817) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.content.res.resources.loaddrawable(resources.java:2854) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.content.res.typedarray.getdrawable(typedarray.java:602) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.view.view.<init>(view.java:3460) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.view.viewgroup.<init>(viewgroup.java:446) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.widget.linearlayout.<init>(linearlayout.java:176) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.widget.linearlayout.<init>(linearlayout.java:172) 05-08 10:37:20.123: i/dalvikvm(25740): @ java.lang.reflect.constructor.constructnative(native method) 05-08 10:37:20.123: i/dalvikvm(25740): @ java.lang.reflect.constructor.newinstance(constructor.java:417) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.view.layoutinflater.createview(layoutinflater.java:593) 05-08 10:37:20.123: i/dalvikvm(25740): @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:56) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.view.layoutinflater.oncreateview(layoutinflater.java:666) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:691) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.view.layoutinflater.inflate(layoutinflater.java:467) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.view.layoutinflater.inflate(layoutinflater.java:397) 05-08 10:37:20.123: i/dalvikvm(25740): @ com.travelstorysgps.travelstorys.fragmentconnect.oncreateview(fragmentconnect.java:73) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.support.v4.app.fragment.performcreateview(fragment.java:1460) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:911) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1088) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.support.v4.app.backstackrecord.run(backstackrecord.java:682) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1444) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.support.v4.app.fragmentmanagerimpl$1.run(fragmentmanager.java:429) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.os.handler.handlecallback(handler.java:725) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.os.handler.dispatchmessage(handler.java:92) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.os.looper.loop(looper.java:137) 05-08 10:37:20.123: i/dalvikvm(25740): @ android.app.activitythread.main(activitythread.java:5293) 05-08 10:37:20.123: i/dalvikvm(25740): @ java.lang.reflect.method.invokenative(native method) 05-08 10:37:20.123: i/dalvikvm(25740): @ java.lang.reflect.method.invoke(method.java:511) 05-08 10:37:20.123: i/dalvikvm(25740): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1102) 05-08 10:37:20.123: i/dalvikvm(25740): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:869) 05-08 10:37:20.123: i/dalvikvm(25740): @ dalvik.system.nativestart.main(native method) 05-08 10:37:20.123: d/skia(25740): --- decoder->decode returned false 05-08 10:37:20.123: d/androidruntime(25740): shutting down vm 05-08 10:37:20.123: w/dalvikvm(25740): threadid=1: thread exiting uncaught exception (group=0x41186ac8) 05-08 10:37:20.133: e/androidruntime(25740): fatal exception: main 05-08 10:37:20.133: e/androidruntime(25740): android.view.inflateexception: binary xml file line #2: error inflating class <unknown> 05-08 10:37:20.133: e/androidruntime(25740): @ android.view.layoutinflater.createview(layoutinflater.java:619) 05-08 10:37:20.133: e/androidruntime(25740): @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:56) 05-08 10:37:20.133: e/androidruntime(25740): @ android.view.layoutinflater.oncreateview(layoutinflater.java:666) 05-08 10:37:20.133: e/androidruntime(25740): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:691) 05-08 10:37:20.133: e/androidruntime(25740): @ android.view.layoutinflater.inflate(layoutinflater.java:467) 05-08 10:37:20.133: e/androidruntime(25740): @ android.view.layoutinflater.inflate(layoutinflater.java:397) 05-08 10:37:20.133: e/androidruntime(25740): @ com.travelstorysgps.travelstorys.fragmentconnect.oncreateview(fragmentconnect.java:73) 05-08 10:37:20.133: e/androidruntime(25740): @ android.support.v4.app.fragment.performcreateview(fragment.java:1460) 05-08 10:37:20.133: e/androidruntime(25740): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:911) 05-08 10:37:20.133: e/androidruntime(25740): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1088) 05-08 10:37:20.133: e/androidruntime(25740): @ android.support.v4.app.backstackrecord.run(backstackrecord.java:682) 05-08 10:37:20.133: e/androidruntime(25740): @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1444) 05-08 10:37:20.133: e/androidruntime(25740): @ android.support.v4.app.fragmentmanagerimpl$1.run(fragmentmanager.java:429) 05-08 10:37:20.133: e/androidruntime(25740): @ android.os.handler.handlecallback(handler.java:725) 05-08 10:37:20.133: e/androidruntime(25740): @ android.os.handler.dispatchmessage(handler.java:92) 05-08 10:37:20.133: e/androidruntime(25740): @ android.os.looper.loop(looper.java:137) 05-08 10:37:20.133: e/androidruntime(25740): @ android.app.activitythread.main(activitythread.java:5293) 05-08 10:37:20.133: e/androidruntime(25740): @ java.lang.reflect.method.invokenative(native method) 05-08 10:37:20.133: e/androidruntime(25740): @ java.lang.reflect.method.invoke(method.java:511) 05-08 10:37:20.133: e/androidruntime(25740): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1102) 05-08 10:37:20.133: e/androidruntime(25740): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:869) 05-08 10:37:20.133: e/androidruntime(25740): @ dalvik.system.nativestart.main(native method) 05-08 10:37:20.133: e/androidruntime(25740): caused by: java.lang.reflect.invocationtargetexception 05-08 10:37:20.133: e/androidruntime(25740): @ java.lang.reflect.constructor.constructnative(native method) 05-08 10:37:20.133: e/androidruntime(25740): @ java.lang.reflect.constructor.newinstance(constructor.java:417) 05-08 10:37:20.133: e/androidruntime(25740): @ android.view.layoutinflater.createview(layoutinflater.java:593) 05-08 10:37:20.133: e/androidruntime(25740): ... 21 more 05-08 10:37:20.133: e/androidruntime(25740): caused by: java.lang.outofmemoryerror 05-08 10:37:20.133: e/androidruntime(25740): @ android.graphics.bitmapfactory.nativedecodeasset(native method) 05-08 10:37:20.133: e/androidruntime(25740): @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:596) 05-08 10:37:20.133: e/androidruntime(25740): @ android.graphics.bitmapfactory.decoderesourcestream(bitmapfactory.java:444) 05-08 10:37:20.133: e/androidruntime(25740): @ android.graphics.drawable.drawable.createfromresourcestream(drawable.java:817) 05-08 10:37:20.133: e/androidruntime(25740): @ android.content.res.resources.loaddrawable(resources.java:2854) 05-08 10:37:20.133: e/androidruntime(25740): @ android.content.res.typedarray.getdrawable(typedarray.java:602) 05-08 10:37:20.133: e/androidruntime(25740): @ android.view.view.<init>(view.java:3460) 05-08 10:37:20.133: e/androidruntime(25740): @ android.view.viewgroup.<init>(viewgroup.java:446) 05-08 10:37:20.133: e/androidruntime(25740): @ android.widget.linearlayout.<init>(linearlayout.java:176) 05-08 10:37:20.133: e/androidruntime(25740): @ android.widget.linearlayout.<init>(linearlayout.java:172) 05-08 10:37:20.133: e/androidruntime(25740): ... 24 more
(@arash's answer provides workaround, attempt explain why may work.)
so have rather big image in drawable
resource directory, reference in layout xml file, , out of memory error @ runtime when inflating it.
when loading drawable resources, android perform pre-scaling if deems necessary. official documentation:
based on density of current screen, system uses size- or density-specific resources application , displays them without scaling. if resources not available in correct density, system loads default resources , scales them or down needed match current screen's density. system assumes default resources (those directory without configuration qualifiers) designed baseline screen density (mdpi), unless loaded density-specific resource directory.
this means 2 things:
- if there's no resource of density of environment application running on, system take resource of density , scale (up or down) match target density
- resources put in
drawable
directory assumed targetingmdpi
density
so you're running on xxhdpi phone. system wants load learn_more
drawable resource paint on ivlearnmore
widget. in drawable-xxhdpi
in priority won't find there, take closest 1 finds, in case 1 in drawable
directory (which assumes targeting mdpi density), , load memory scaling by factor of 3 lot if image file big , can require more memory available application (and cause out of memory error).
this why loaded fine on old crappy 2.3 device: device of mdpi or hdpi density , system didn't try upscale or did factor of 1.5.
the main thing here being put resource suitable xxhdpi (or more ?) density in mdpi directory.
so have several options:
- provide 1 resource appropriately sized per density (i.e. 1 in each
drawable-*
directory): best avoid problem, when possible - if have 1 version of resource, put in directory matching density (
drawable
being equivalentdrawable-mdpi
!), in case maybedrawable-xxhdpi
(depends on resource) - put resource in
drawable-nodpi
directory, prevent system performing pre-scaling of resource (but typically density-agnostic resources e.g. resize @ runtime)
Comments
Post a Comment