Out of memory on a 3686416-byte allocation, android.view.InflateException: Binary XML file line #1: Error inflating class <unknown> -


i getting multiple errors after adding background image parent relativelayout after calling inside asynctask (this error goes out using emulator when used actual device, stack trace not displaying or fine):

public class userauthtask extends asynctask<string, void, string> {     private boolean success = false;      @override     protected string doinbackground(string... path) {         // todo: attempt authentication against network service.         try {             // simulate network access.             thread.sleep(2000);         } catch (interruptedexception e) {             return null;         }          log.d(constant.tag_auth, path[0]);         string apirequestreturn = webserviceutil.getrequest(path[0]);         if (apirequestreturn.equals("")) {             log.d(constant.tag_auth, "webservice request null");             return null;         } else {             log.d(constant.tag_auth, "webservice request has data");             return apirequestreturn;         }     }      @override     protected void onpostexecute(string result) {         userauthtask = null;         showprogress(false);          super.onpostexecute(null);          if (boolean.parseboolean(result) == true) {             // account exists, return true if password matches.             success  = true;         }          if (success) {             // start main activity if auth successful             intent = new intent(authactivity.this, nextactivity.class);             startactivity(i);              application.shorttoast(getapplicationcontext().getresources().getstring(r.string.auth_success));             log.d(constant.tag_auth, "authentication successful");         } else {             application.shorttoast(getapplicationcontext().getresources().getstring(r.string.invalid_account));             log.d(constant.tag_auth, getstring(r.string.invalid_account));             log.d(constant.tag_auth, "authentication failed");              finish();         }     }      @override     protected void oncancelled() {         userauthtask = null;         showprogress(false);     } } 

this nextactivity:

public class nextactivity extends activity {  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_next); }  @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.next, menu);     return true; }} 

and cause of errors line android:background="@drawable/master_background" @ activity_next.xml:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/master_background" > 

this image color brown, have use image use resources(images) given designer. don't understand when removed line android:background="@drawable/master_background" code goes fine. way here's stack trace:

    07-15 11:51:20.616: e/androidruntime(2392): fatal exception: main     07-15 11:51:20.616: e/androidruntime(2392): java.lang.runtimeexception: unable start activity componentinfo{com.sample/com.sample.nextactivity}: android.view.inflateexception: binary xml file line #1: error inflating class <unknown>     07-15 11:51:20.616: e/androidruntime(2392):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2180)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2230)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.app.activitythread.access$600(activitythread.java:141)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.app.activitythread$h.handlemessage(activitythread.java:1234)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.os.handler.dispatchmessage(handler.java:99)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.os.looper.loop(looper.java:137)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.app.activitythread.main(activitythread.java:5041)     07-15 11:51:20.616: e/androidruntime(2392):     @ java.lang.reflect.method.invokenative(native method)     07-15 11:51:20.616: e/androidruntime(2392):     @ java.lang.reflect.method.invoke(method.java:511)     07-15 11:51:20.616: e/androidruntime(2392):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793)     07-15 11:51:20.616: e/androidruntime(2392):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560)     07-15 11:51:20.616: e/androidruntime(2392):     @ dalvik.system.nativestart.main(native method)     07-15 11:51:20.616: e/androidruntime(2392): caused by: android.view.inflateexception: binary xml file line #1: error inflating class <unknown>     07-15 11:51:20.616: e/androidruntime(2392):     @ android.view.layoutinflater.createview(layoutinflater.java:613)     07-15 11:51:20.616: e/androidruntime(2392):     @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:56)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.view.layoutinflater.oncreateview(layoutinflater.java:660)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:685)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.view.layoutinflater.inflate(layoutinflater.java:466)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.view.layoutinflater.inflate(layoutinflater.java:396)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.view.layoutinflater.inflate(layoutinflater.java:352)     07-15 11:51:20.616: e/androidruntime(2392):     @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:270)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.app.activity.setcontentview(activity.java:1881)     07-15 11:51:20.616: e/androidruntime(2392):     @ com.sample.nextactivity.oncreate(nextactivity.java:12)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.app.activity.performcreate(activity.java:5104)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.app.instrumentation.callactivityoncreate(insttrumentaion.java:1080)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2144)     07-15 11:51:20.616: e/androidruntime(2392):     ... 11 more     07-15 11:51:20.616: e/androidruntime(2392): caused by: java.lang.reflect.invocationtargetexception     07-15 11:51:20.616: e/androidruntime(2392):     @ java.lang.reflect.constructor.constructnative(native method)     07-15 11:51:20.616: e/androidruntime(2392):     @ java.lang.reflect.constructor.newinstance(constructor.java:417)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.view.layoutinflater.createview(layoutinflater.java:587)     07-15 11:51:20.616: e/androidruntime(2392):     ... 23 more     07-15 11:51:20.616: e/androidruntime(2392): caused by: java.lang.outofmemoryerror     07-15 11:51:20.616: e/androidruntime(2392):     @ android.graphics.bitmapfactory.nativedecodeasset(native method)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:502)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.graphics.bitmapfactory.decoderesourcestream(bitmapfactory.java:355)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.graphics.drawable.drawable.createfromresourcestream(drawable.java:785)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.content.res.resources.loaddrawable(resources.java:1965)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.content.res.typedarray.getdrawable(typedarray.java:601)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.view.view.<init>(view.java:3330)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.view.view.<init>(view.java:3259)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.view.viewgroup.<init>(viewgroup.java:425)     07-15 11:51:20.616: e/androidruntime(2392):     @ android.widget.relativelayout.<init>(relativelayout.java:210)     07-15 11:51:20.616: e/androidruntime(2392):     ... 26 more 

edit: image size of master_background 1080*1920 size of 1.01 mb, affect "out of memory" error? since comes out in emulator not in actual device. want explanation problem. thank much.

check android developer link. , have images in appropriate folder appropriate sizes. when don't have images in appropriate size, os try adjust image size , causes out of memory exception.

https://developer.android.com/guide/practices/screens_support.html


Comments