Android app crash in 512mb ram mobile -
hi created 1 android application , uploaded in play store, in app used navigation drawer navigate 1 activity another.
my app working fine in maximum no of mobiles has 1 gb ram , latest os kitkat or lollipop, in 512 mb ram mobile , in ice_cream_sandwich version app closing after start up, saying "unfortunately app has stopped". problem arising in few mobiles (i saying based upon user comments in play store).
and minimum , maximum sdk version
<uses-sdk android:minsdkversion="14" android:targetsdkversion="19" />
and didn't add appcompat v7 library, if add java class files showing error.
now need is, need know why crash happening , how fix this.
i made search in couldn't able find proper solution need.
and crash report got in play store
java.lang.nullpointerexception in android.graphics.drawable.insetdrawable.isstateful java.lang.runtimeexception: unable start activity componentinfo{com.imaginet.everwinmatriculation/com.imaginet.everwinmatriculation.mainactivity}: java.lang.nullpointerexception @ android.app.activitythread.performlaunchactivity(activitythread.java:2121) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2146) @ android.app.activitythread.access$700(activitythread.java:140) @ android.app.activitythread$h.handlemessage(activitythread.java:1238) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:177) @ android.app.activitythread.main(activitythread.java:4947) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1038) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:805) @ dalvik.system.nativestart.main(native method) caused by: java.lang.nullpointerexception @ android.graphics.drawable.insetdrawable.isstateful(insetdrawable.java:208) @ android.widget.imageview.updatedrawable(imageview.java:697) @ android.widget.imageview.setimagedrawable(imageview.java:410) @ android.support.v4.app.actionbardrawertogglehoneycomb.setactionbarupindicator (actionbardrawertogglehoneycomb.java:62)at android.support.v4.app.actionbardrawertoggle$actionbardrawertoggleimplhc .setactionbarupindicator(actionbardrawertoggle.java:134) @ android.support.v4.app.actionbardrawertoggle.setactionbarupindicator (actionbardrawertoggle.java:400) @ android.support.v4.app.actionbardrawertoggle.syncstate(actionbardrawertoggle.java:258) @ com.imaginet.everwinmatriculation.mainactivity.onpostcreate(mainactivity.java:291) @ android.app.instrumentation.callactivityonpostcreate(instrumentation.java:1157) @ android.app.activitythread.performlaunchactivity(activitythread.java:2104) ... 11 more
and mainactivity is...
public class mainactivity extends activity { private drawerlayout mdrawerlayout; private listview mdrawerlist; private actionbardrawertoggle mdrawertoggle; // nav drawer title private charsequence mdrawertitle; // used store app title private charsequence mtitle; // slide menu items private string[] navmenutitles; private typedarray navmenuicons; private arraylist<navdraweritem> navdraweritems; private navdrawerlistadapter adapter; context context; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //from - internet connectivity checking connectivitymanager cn=(connectivitymanager)getsystemservice(context.connectivity_service); networkinfo nf=cn.getactivenetworkinfo(); if(nf != null && nf.isconnected()==true ) { toast.maketext(this, "you have active internet connection", toast.length_long).show(); } else { toast.maketext(this, "network not available", toast.length_long).show(); alertdialog.builder builder = new alertdialog.builder(this); builder.setmessage("you don't have active internet connection, click ok exit") .setcancelable(false) .setpositivebutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { //do things finish(); } }); alertdialog alert = builder.create(); alert.show(); } //upto - internet connectivity checking mtitle = mdrawertitle = gettitle(); // load slide menu items navmenutitles = getresources().getstringarray(r.array.nav_drawer_items); // nav drawer icons resources navmenuicons = getresources() .obtaintypedarray(r.array.nav_drawer_icons); mdrawerlayout = (drawerlayout) findviewbyid(r.id.drawer_layout); mdrawerlist = (listview) findviewbyid(r.id.list_slidermenu); navdraweritems = new arraylist<navdraweritem>(); // adding nav drawer items array // home navdraweritems.add(new navdraweritem(navmenutitles[0], navmenuicons.getresourceid(0, -1))); // navdraweritems.add(new navdraweritem(navmenutitles[1], navmenuicons.getresourceid(1, -1))); // principal speech navdraweritems.add(new navdraweritem(navmenutitles[2], navmenuicons.getresourceid(3, -1))); // circulars navdraweritems.add(new navdraweritem(navmenutitles[3], navmenuicons.getresourceid(4, -1), false, "22")); // internal events navdraweritems.add(new navdraweritem(navmenutitles[4], navmenuicons.getresourceid(6, -1))); //external events navdraweritems.add(new navdraweritem(navmenutitles[5], navmenuicons.getresourceid(6, -1))); // academic calendar navdraweritems.add(new navdraweritem(navmenutitles[6], navmenuicons.getresourceid(6, -1))); // admissions navdraweritems.add(new navdraweritem(navmenutitles[7], navmenuicons.getresourceid(7, -1))); // competition navdraweritems.add(new navdraweritem(navmenutitles[8], navmenuicons.getresourceid(8, -1))); // class work navdraweritems.add(new navdraweritem(navmenutitles[9], navmenuicons.getresourceid(9, -1))); // home work navdraweritems.add(new navdraweritem(navmenutitles[10], navmenuicons.getresourceid(10, -1))); // training & test navdraweritems.add(new navdraweritem(navmenutitles[11], navmenuicons.getresourceid(11, -1))); // examination navdraweritems.add(new navdraweritem(navmenutitles[12], navmenuicons.getresourceid(12, -1))); // recycle typed array navmenuicons.recycle(); mdrawerlist.setonitemclicklistener(new slidemenuclicklistener()); // setting nav drawer list adapter adapter = new navdrawerlistadapter(getapplicationcontext(), navdraweritems); mdrawerlist.setadapter(adapter); // enabling action bar app icon , behaving toggle button getactionbar().setdisplayhomeasupenabled(true); getactionbar().sethomebuttonenabled(true); mdrawertoggle = new actionbardrawertoggle(this, mdrawerlayout, r.drawable.ic_drawer, //nav menu toggle icon r.string.app_name, // nav drawer open - description accessibility r.string.app_name // nav drawer close - description accessibility ) { public void ondrawerclosed(view view) { getactionbar().settitle(mtitle); // calling onprepareoptionsmenu() show action bar icons invalidateoptionsmenu(); } public void ondraweropened(view drawerview) { getactionbar().settitle(mdrawertitle); // calling onprepareoptionsmenu() hide action bar icons invalidateoptionsmenu(); } }; mdrawerlayout.setdrawerlistener(mdrawertoggle); if (savedinstancestate == null) { // on first time display view first nav item displayview(0); } //following 1 line added onbackpressed method mdrawerlayout.setfocusableintouchmode(false); } /** * slide menu item click listener * */ private class slidemenuclicklistener implements listview.onitemclicklistener { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { // display view selected nav drawer item displayview(position); } } @override public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // toggle nav drawer on selecting action bar app icon/title if (mdrawertoggle.onoptionsitemselected(item)) { return true; } // handle action bar actions click switch (item.getitemid()) { case r.id.action_settings: return true; default: return super.onoptionsitemselected(item); } } /* * * called when invalidateoptionsmenu() triggered */ @override public boolean onprepareoptionsmenu(menu menu) { // if nav drawer opened, hide action items boolean draweropen = mdrawerlayout.isdraweropen(mdrawerlist); menu.finditem(r.id.action_settings).setvisible(!draweropen); return super.onprepareoptionsmenu(menu); } /** * diplaying fragment view selected nav drawer list item * */ private void displayview(int position) { // update main content replacing fragments fragment fragment = null; switch (position) { case 0: fragment = new homefragment(); break; case 1: fragment = new aboutusfragment(); break; case 2: fragment = new principalspeechfragment(); break; case 3: fragment = new circularsfragment(); break; case 4: fragment = new eventsfragment(); break; case 5: fragment = new externaleventsfragment(); break; case 6: fragment = new ac_calenderfragment(); break; case 7: fragment = new admissionsfragment(); break; case 8: fragment = new competitionfragment(); break; case 9: fragment = new classworkfragment(); break; case 10: fragment = new homeworkfragment(); break; case 11: fragment = new trainingtestfragment(); break; case 12: fragment = new examinationfragment(); break; default: break; } if (fragment != null) { fragmentmanager fragmentmanager = getfragmentmanager(); fragmentmanager.begintransaction() .replace(r.id.frame_container, fragment).commit(); // update selected item , title, close drawer mdrawerlist.setitemchecked(position, true); mdrawerlist.setselection(position); settitle(navmenutitles[position]); mdrawerlayout.closedrawer(mdrawerlist); } else { // error in creating fragment log.e("mainactivity", "error in creating fragment"); } } @override public void settitle(charsequence title) { mtitle = title; getactionbar().settitle(mtitle); } /** * when using actionbardrawertoggle, must call during * onpostcreate() , onconfigurationchanged()... */ @override protected void onpostcreate(bundle savedinstancestate) { super.onpostcreate(savedinstancestate); // sync toggle state after onrestoreinstancestate has occurred. mdrawertoggle.syncstate(); } @override public void onconfigurationchanged(configuration newconfig) { super.onconfigurationchanged(newconfig); // pass configuration change drawer toggls if (mdrawerlayout != null) { mdrawertoggle.onconfigurationchanged(newconfig); } } @override public void onbackpressed() { // todo auto-generated method stub //super.onbackpressed(); //upcmoning line confirm exiting new alertdialog.builder(this) .setmessage("are sure want exit?") .setcancelable(false) .setpositivebutton("yes", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { mainactivity.this.finish(); } }) .setnegativebutton("no", null) .show(); } }
i believe solution problem this:
just add line application in manifest file:
android:largeheap="true"
so manifest file should application should this:
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:largeheap="true" android:theme="@android:style/theme.light.notitlebar.fullscreen" > <activity android:name=".mainactivity" android:label="@string/app_name" android:theme="@android:style/theme.light.notitlebar.fullscreen" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application>
Comments
Post a Comment