android - Fatal Exception Main in my app -


i keep getting error when try launch app

11-10 19:02:51.700 8446-8446/com.example.android.stratosphere e/androidruntime: fatal exception: main                                                                             process: com.example.android.stratosphere, pid: 8446                                                                             java.lang.runtimeexception: unable start activity componentinfo{com.example.android.stratosphere/com.example.android.stratosphere.mainactivity}: android.view.inflateexception: binary xml file line #2: binary xml file line #2: error inflating class <unknown>                                                                                 @ android.app.activitythread.performlaunchactivity(activitythread.java:2426)                                                                                 @ android.app.activitythread.handlelaunchactivity(activitythread.java:2490)                                                                                 @ android.app.activitythread.-wrap11(activitythread.java)                                                                                 @ android.app.activitythread$h.handlemessage(activitythread.java:1354)                                                                                 @ android.os.handler.dispatchmessage(handler.java:102)                                                                                 @ android.os.looper.loop(looper.java:148)                                                                                 @ android.app.activitythread.main(activitythread.java:5443)                                                                                 @ java.lang.reflect.method.invoke(native method)                                                                                 @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:728)                                                                                 @ com.android.internal.os.zygoteinit.main(zygoteinit.java:618)                                                                              caused by: android.view.inflateexception: binary xml file line #2: binary xml file line #2: error inflating class <unknown>                                                                                 @ android.view.layoutinflater.inflate(layoutinflater.java:539)                                                                                 @ android.view.layoutinflater.inflate(layoutinflater.java:423)                                                                                 @ android.view.layoutinflater.inflate(layoutinflater.java:374)                                                                                 @ com.android.internal.policy.phonewindow.setcontentview(phonewindow.java:393)                                                                                 @ android.app.activity.setcontentview(activity.java:2170)                                                                                 @ com.example.android.stratosphere.mainactivity.oncreate(mainactivity.java:54)                                                                                 @ android.app.activity.performcreate(activity.java:6245)                                                                                 @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1130)                                                                                 @ android.app.activitythread.performlaunchactivity(activitythread.java:2379)                                                                                 @ android.app.activitythread.handlelaunchactivity(activitythread.java:2490)                                                                                  @ android.app.activitythread.-wrap11(activitythread.java)                                                                                  @ android.app.activitythread$h.handlemessage(activitythread.java:1354)                                                                                  @ android.os.handler.dispatchmessage(handler.java:102)                                                                                  @ android.os.looper.loop(looper.java:148)                                                                                  @ android.app.activitythread.main(activitythread.java:5443)                                                                                  @ java.lang.reflect.method.invoke(native method)                                                                                  @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:728)                                                                                  @ com.android.internal.os.zygoteinit.main(zygoteinit.java:618)                                                                               caused by: android.view.inflateexception: binary xml file line #2: error inflating class <unknown>                                                                                 @ android.view.layoutinflater.createview(layoutinflater.java:645)                                                                                 @ com.android.internal.policy.phonelayoutinflater.oncreateview(phonelayoutinflater.java:58)                                                                                 @ android.view.layoutinflater.oncreateview(layoutinflater.java:694)                                                                                 @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:762)                                                                                 @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:704)                                                                                 @ android.view.layoutinflater.inflate(layoutinflater.java:492)                                                                                 @ android.view.layoutinflater.inflate(layoutinflater.java:423)                                                                                  @ android.view.layoutinflater.inflate(layoutinflater.java:374)                                                                                  @ com.android.internal.policy.phonewindow.setcontentview(phonewindow.java:393)                                                                                  @ android.app.activity.setcontentview(activity.java:2170)                                                                                  @ com.example.android.stratosphere.mainactivity.oncreate(mainactivity.java:54)                                                                                  @ android.app.activity.performcreate(activity.java:6245)                                                                                  @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1130)                                                                                  @ android.app.activitythread.performlaunchactivity(activitythread.java:2379)                                                                                  @ android.app.activitythread.handlelaunchactivity(activitythread.java:2490)                                                                                  @ android.app.activitythread.-wrap11(activitythread.java)                                                                                  @ android.app.activitythread$h.handlemessage(activitythread.java:1354)                                                                                  @ android.os.handler.dispatchmessage(handler.java:102)                                                                                  @ android.os.looper.loop(looper.java:148)                                                                                  @ android.app.activitythread.main(activitythread.java:5443)                                                                                  @ java.lang.reflect.method.invoke(native method)                                                                                  @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:728)                                                                                  @ com.android.internal.os.zygoteinit.main(zygoteinit.java:618)                                                                               caused by: java.lang.reflect.invocationtargetexception                                                                                 @ java.lang.reflect.constructor.newinstance(native method)                                                                                 @ android.view.layoutinflater.createview(layoutinflater.java:619)                                                                                 @ com.android.internal.policy.phonelayoutinflater.oncreateview(phonelayoutinflater.java:58)                                                                                  @ android.view.layoutinflater.oncreateview(layoutinflater.java:694)                                                                                  @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:762)                                                                                  @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:704)                                                                                  @ android.view.layoutinflater.inflate(layoutinflater.java:492)                                                                                  @ android.view.layoutinflater.inflate(layoutinflater.java:423)                                                                                  @ android.view.layoutinflater.inflate(layoutinflater.java:374)                                                                                  @ com.android.internal.policy.phonewindow.setcontentview(phonewindow.java:393)                                                                                  @ android.app.activity.setcontentview(activity.java:2170)                                                                                  @ com.example.android.stratosphere.mainactivity.oncreate(mainactivity.java:54)                                                                                  @ android.app.activity.performcreate(activity.java:6245)                                                                                  @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1130)                                                                                  @ android.app.activitythread.performlaunchactivity(activitythread.java:2379)                                                                                  @ android.app.activitythread.handlelaunchactivity(activitythread.java:2490)                                                                                  @ android.app.activitythread.-wrap11(activitythread.java)                                                                                  @ android.app.activitythread$h.handlemessage(activitythread.java:1354)                                                                                  @ android.os.handler.dispatchmessage(handler.java:102)                                                                                  @ android.os.looper.loop(looper.java:148)                                                                                  @ android.app.activitythread.main(activitythread.java:5443)                                                                                  @ java.lang.reflect.method.invoke(native method)                                                                                  @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:728)                                                                                  @ com.android.internal.os.zygoteinit.main(zygoteinit.java:618)                                                                               caused by: java.lang.outofmemoryerror: failed allocate 155750412 byte allocation 2425818 free bytes , 89mb until oom                                                                                 @ dalvik.system.vmruntime.newnonmovablearray(native method)                                                                                 @ android.graphics.bitmapfactory.nativedecodeasset(native method)                                                                                 @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:609)                                                                                 @ android.graphics.bitmapfactory.decoderesourcestream(bitmapfactory.java:444)                                                                                 @ android.graphics.drawable.drawable.createfromresourcestream(drawable.java:1080)                                                                                 @ android.content.res.resources.loaddrawableforcookie(resources.java:2638)                                                                                 @ android.content.res.resources.loaddrawable(resources.java:2543)                                                                                 @ android.content.res.typedarray.getdrawable(typedarray.java:870)                                                                                 @ android.view.view.<init>(view.java:3951)                                                                                 @ android.view.viewgroup.<init>(viewgroup.java:573)                                                                                 @ android.widget.linearlayout.<init>(linearlayout.java:203)                                                                                 @ android.widget.linearlayout.<init>(linearlayout.java:199)                                                                                 @ android.widget.linearlayout.<init>(linearlayout.java:195)                                                                                 @ java.lang.reflect.constructor.newinstance(native method)                                                                                  @ android.view.layoutinflater.createview(layoutinflater.java:619)                                                                                  @ com.android.internal.policy.phonelayoutinflater.oncreateview(phonelayoutinflater.java:58)                                                                                  @ android.view.layoutinflater.oncreateview(layoutinflater.java:694)                                                                                  @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:762)                                                                                  @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:704)                                                                                  @ android.view.layoutinflater.inflate(layoutinflater.java:492)                                                                                  @ android.view.layoutinflater.inflate(layoutinflater.java:423)                                                                                  @ android.view.layoutinflater.inflate(layoutinflater.java:374)                                                                                  @ com.android.internal.policy.phonewindow.setcontentview(phonewindow.java:393)                                                                                  @ android.app.activity.setcontentview(activity.java:2170)                                                                                  @ com.example.android.stratosphere.mainactivity.oncreate(mainactivity.java:54)                                                                                  @ android.app.activity.performcreate(activity.java:6245)                                                                                  @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1130)                                                                                  @ android.app.activitythread.performlaunchactivity(activitythread.java:2379)                                                                                  @ android.app.activitythread.handlelaunchactivity(activitythread.java:2490)                                                                                  @ android.app.activitythread.-wrap11(activitythread.java)                                                                                  @ android.app.activitythread$h.handlemessage(activitythread.java:1354)                                                                                  @ android.os.handler.dispatchmessage(handler.java:102)                                                                                  @ android.os.looper.loop(looper.java:148)                                                                                  @ android.app.activitythread.main(activitythread.java:5443)                                                                                  @ java.lang.reflect.method.invoke(native method)                                                                                  @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:728)                                                                                  @ com.android.internal.os.zygoteinit.main(zygoteinit.java:618)  

my main activity code

package com.example.android.stratosphere;   import android.app.activity; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.net.uri; import android.os.asynctask; import android.os.bundle; import android.util.log; import android.view.menu; import android.view.view; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.imageview; import android.widget.linearlayout; import android.widget.spinner; import android.widget.textview;  import com.google.android.gms.appindexing.action; import com.google.android.gms.appindexing.appindex; import com.google.android.gms.common.api.googleapiclient;  import org.json.jsonexception;  import static com.example.android.stratosphere.r.id.time; import static java.util.calendar.pm;  public class mainactivity extends activity implements adapterview.onitemselectedlistener {   private textview citytext; private textview conddescr; private textview temp; private textview press; private textview windspeed; private textview winddeg; private string location; private textview hum; private imageview imgview; private spinner spinner; private static final string[] paths = {"choose location", "plymouth", "olveston", "woodlands", "cheapend", "brades", "soldier ghaut", "geralds"};  /**  * attention: auto-generated implement app indexing api.  * see https://g.co/appindexing/androidstudio more information.  */ private googleapiclient client; jsonweathertask task;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     string location = "london,uk";      citytext = (textview) findviewbyid(r.id.citytext);     citytext.settext("montserrat");     conddescr = (textview) findviewbyid(r.id.conddescr);     temp = (textview) findviewbyid(r.id.temperature_tv);     hum = (textview) findviewbyid(r.id.humidity_tv);     press = (textview) findviewbyid(r.id.atmospress_tv);     windspeed = (textview) findviewbyid(r.id.wind_speed_tv);     winddeg = (textview) findviewbyid(r.id.wind_direction_tv);     //imgview = (imageview) findviewbyid(r.id.condicon);       task = new  jsonweathertask();     task.execute(new string[]{location});       spinner = (spinner) findviewbyid(r.id.location_spin);     arrayadapter<string> adapter = new arrayadapter<string>(mainactivity.this,             android.r.layout.simple_spinner_item, paths);      adapter.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item);     spinner.setadapter(adapter);     spinner.setonitemselectedlistener(this);      // attention: auto-generated implement app indexing api.     // see https://g.co/appindexing/androidstudio more information.     client = new googleapiclient.builder(this).addapi(appindex.api).build(); }    public void onitemselected(adapterview<?> parent, view v, int position, long id) {      switch (position) {         case 0:             // whatever want happen when first item gets selected             break;         case 1:             // whatever want happen when second item gets selected             location = "q=plymouth,ms";             break;          case 2:             // whatever want happen when third item gets selected             location = "q=olveston,ms";          break;          case 3:             // whatever want happen when fourth item gets selected             location = "q=woodlands,ms";             break;          case 4:             // whatever want happen when fifth item gets selected             location = "q=cheapend,ms";             break;          case 5:             // whatever want happen when sixth item gets selected             location = "q=brades,ms";             break;          case 6:             // whatever want happen when seventh item gets selected             location = "q=blackghautbottom,ms";             break;           case 7:             // whatever want happen when eighth item gets selected             location = "q=geralds,ms";             break;       } }  @override public void onnothingselected(adapterview<?> parent) {  }   @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.main, menu);     return true; }  @override public void onstart() {     super.onstart();      // attention: auto-generated implement app indexing api.     // see https://g.co/appindexing/androidstudio more information.     client.connect();     action viewaction = action.newaction(             action.type_view, // todo: choose action type.             "main page", // todo: define title content shown.             // todo: if have web page content matches app activity's content,             // make sure auto-generated web page url correct.             // otherwise, set url null.             uri.parse("http://host/path"),             // todo: make sure auto-generated app url correct.             uri.parse("android-app://com.example.android.stratosphere/http/host/path")     );     appindex.appindexapi.start(client, viewaction); }  @override public void onstop() {     super.onstop();      // attention: auto-generated implement app indexing api.     // see https://g.co/appindexing/androidstudio more information.     action viewaction = action.newaction(             action.type_view, // todo: choose action type.             "main page", // todo: define title content shown.             // todo: if have web page content matches app activity's content,             // make sure auto-generated web page url correct.             // otherwise, set url null.             uri.parse("http://host/path"),             // todo: make sure auto-generated app url correct.             uri.parse("android-app://com.example.android.stratosphere/http/host/path")     );     appindex.appindexapi.end(client, viewaction);     client.disconnect(); }   private class jsonweathertask extends asynctask<string, void, weather> {      @override     protected weather doinbackground(string... params) {         weather weather = new weather();         string data = ((new weatherhttpclient()).getweatherdata(params[0]));         //string data = ((new weatherhttpclient()).getweatherdata(location));         log.e("beg", data);         try {             log.e("try", "before weather called");             weather = jsonweatherparser.getweather(data);              log.e("test2", "doesthiswork");              // let's retrieve icon             weather.icondata = ((new weatherhttpclient()).getimage(weather.currentcondition.geticon()));          } catch (jsonexception e) {             log.e("test3", "catchtest");             e.printstacktrace();         }           // log.e( "pressure","" + weather.currentcondition.getpressure() + " hpa");         //      log.e("city", "" + weather.location.getcity()+"");           return weather;      }       @override     protected void onpostexecute(weather weather) {         super.onpostexecute(weather);          //     if (weather.icondata != null && weather.icondata.length > 0) {         //         bitmap img = bitmapfactory.decodebytearray(weather.icondata, 0, weather.icondata.length);         //         imgview.setimagebitmap(img);         //   }          //citytext = (textview) findviewbyid(r.id.citytext);         //citytext.settext("montserrat");           if (weather.location.getcity() == null && weather.location.getcountry() == null) {             log.e("getcity", "yes");         } else {             log.e("getcity", weather.location.getcity());             log.e("getcountry", weather.location.getcountry());             citytext.settext(weather.location.getcity() + "," + weather.location.getcountry());             //citytext.settext("place");         }          if (weather.currentcondition.getcondition() == null && weather.currentcondition.getdescr() == null) {             log.e("getcondition", "yes");         } else {             log.e("getdescr", weather.currentcondition.getdescr());             log.e("getcondition", weather.currentcondition.getcondition());             conddescr.settext(weather.currentcondition.getcondition() + "(" + weather.currentcondition.getdescr() + ")");         }           temp.settext("" + math.round((weather.temperature.gettemp() - 273.15)) + "°c");           hum.settext("" + weather.currentcondition.gethumidity() + "%");           press.settext("" + weather.currentcondition.getpressure() + " hpa");           windspeed.settext("" + weather.wind.getspeed() + " mps");           winddeg.settext("" + weather.wind.getdeg() + "°");        }  } } 

i still beginner please understand if code has simple error. not sure why keeps happening since updated android studio recently.

thank you

caused by: java.lang.outofmemoryerror: failed allocate 155750412 byte allocation 2425818 free bytes , 89mb until oom 

you attempting load image take >150mb. equivalent image 12480 pixels on side. large. appears resource associated linearlayout, perhaps via android:background attribute.

so, need to:

  1. identify image is

  2. if put image in res/drawable/, perhaps move res/drawable-nodpi/

  3. if image large, or anywhere close it, reduce resolution of image


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -