java - Unable to launch my android apps. “Shutting down VM” Error -


i'm total newbie java programming, app worked flawleslly until now, can't find cause of error. app shuts down when opening instantly(force close). in advance!

logcat:

09-02 01:07:15.932 15469-15469/com.example.yusuf.bluetoothserver i/art: late-enabling -xcheck:jni 09-02 01:07:15.959 15469-15469/com.example.yusuf.bluetoothserver w/system: classloader referenced unknown path: /data/app/com.example.yusuf.bluetoothserver-2/lib/arm 09-02 01:07:16.011 15469-15469/com.example.yusuf.bluetoothserver w/system: classloader referenced unknown path: /data/app/com.example.yusuf.bluetoothserver-2/lib/arm 09-02 01:07:16.046 15469-15469/com.example.yusuf.bluetoothserver w/xposed: package name /data/data/com.example.yusuf.bluetoothserver/files/instant-run/left/resources.ap_ had retrieved via parser 09-02 01:07:16.081 15469-15469/com.example.yusuf.bluetoothserver v/uuid: 52e2e4ec-0541-4e5e-b599-467ee6fec3aa 09-02 01:07:16.084 15469-15469/com.example.yusuf.bluetoothserver d/androidruntime: shutting down vm 09-02 01:07:16.085 15469-15469/com.example.yusuf.bluetoothserver e/androidruntime: fatal exception: main                                                                                    process: com.example.yusuf.bluetoothserver, pid: 15469                                                                                    theme: themes:{}                                                                                    java.lang.noclassdeffounderror: failed resolution of: landroid/support/v4/content/contextcompat;                                                                                        @ com.example.yusuf.bluetoothserver.mainactivity.requestpermission(mainactivity.java:606)                                                                                        @ com.example.yusuf.bluetoothserver.mainactivity.oncreate(mainactivity.java:122)                                                                                        @ android.app.activity.performcreate(activity.java:7125)                                                                                        @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1108)                                                                                        @ android.app.activitythread.performlaunchactivity(activitythread.java:2415)                                                                                        @ android.app.activitythread.handlelaunchactivity(activitythread.java:2522)                                                                                        @ android.app.activitythread.-wrap11(activitythread.java)                                                                                        @ android.app.activitythread$h.handlemessage(activitythread.java:1363)                                                                                        @ android.os.handler.dispatchmessage(handler.java:102)                                                                                        @ android.os.looper.loop(looper.java:148)                                                                                        @ android.app.activitythread.main(activitythread.java:5475)                                                                                        @ java.lang.reflect.method.invoke(native method)                                                                                        @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726)                                                                                        @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616)                                                                                        @ de.robv.android.xposed.xposedbridge.main(xposedbridge.java:132)                                                                                     caused by: java.lang.classnotfoundexception: didn't find class "android.support.v4.content.contextcompat" on path: dexpathlist[[dex file "/data/data/com.example.yusuf.bluetoothserver/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.example.yusuf.bluetoothserver/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.example.yusuf.bluetoothserver/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.example.yusuf.bluetoothserver/files/instant-run/dex/slice-internal_impl-23.1.1_97e3b4268259621b3c54683f9e2f54c902b84549-classes.dex"],nativelibrarydirectories=[/data/app/com.example.yusuf.bluetoothserver-2/lib/arm, /vendor/lib, /system/lib]]                                                                                        @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:56)                                                                                        @ com.android.tools.fd.runtime.incrementalclassloader$delegateclassloader.findclass(incrementalclassloader.java:90)                                                                                        @ java.lang.classloader.loadclass(classloader.java:511)                                                                                        @ java.lang.classloader.loadclass(classloader.java:469)                                                                                        @ com.example.yusuf.bluetoothserver.mainactivity.requestpermission(mainactivity.java:606)                                                                                         @ com.example.yusuf.bluetoothserver.mainactivity.oncreate(mainactivity.java:122)                                                                                         @ android.app.activity.performcreate(activity.java:7125)                                                                                         @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1108)                                                                                         @ android.app.activitythread.performlaunchactivity(activitythread.java:2415)                                                                                         @ android.app.activitythread.handlelaunchactivity(activitythread.java:2522)                                                                                         @ android.app.activitythread.-wrap11(activitythread.java)                                                                                         @ android.app.activitythread$h.handlemessage(activitythread.java:1363)                                                                                         @ android.os.handler.dispatchmessage(handler.java:102)                                                                                         @ android.os.looper.loop(looper.java:148)                                                                                         @ android.app.activitythread.main(activitythread.java:5475)                                                                                         @ java.lang.reflect.method.invoke(native method)                                                                                         @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726)                                                                                         @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616)                                                                                         @ de.robv.android.xposed.xposedbridge.main(xposedbridge.java:132)                                                                                      suppressed: java.lang.classnotfoundexception: didn't find class "android.support.v4.content.contextcompat" on path: dexpathlist[[zip file "/data/app/com.example.yusuf.bluetoothserver-2/base.apk"],nativelibrarydirectories=[/data/app/com.example.yusuf.bluetoothserver-2/lib/arm, /vendor/lib, /system/lib]]                                                                                        @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:56)                                                                                        @ java.lang.classloader.loadclass(classloader.java:511)                                                                                        @ java.lang.classloader.loadclass(classloader.java:504)                                                                                             ... 16 more                                                                                         suppressed: java.lang.classnotfoundexception: didn't find class "android.support.v4.content.contextcompat" on path: dexpathlist[[dex file "/data/data/com.example.yusuf.bluetoothserver/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.example.yusuf.bluetoothserver/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.example.yusuf.bluetoothserver/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.example.yusuf.bluetoothserver/files/instant-run/dex/slice-internal_impl-23.1.1_97e3b4268259621b3c54683f9e2f54c902b84549-classes.dex"],nativelibrarydirectories=[/data/app/com.example.yusuf.bluetoothserver-2/lib/arm, /vendor/lib, /system/lib]]                                                                                        @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:56)                                                                                        @ com.android.tools.fd.runtime.incrementalclassloader$delegateclassloader.findclass(incrementalclassloader.java:90)                                                                                        @ com.android.tools.fd.runtime.incrementalclassloader.findclass(incrementalclassloader.java:62)                                                                                        @ java.lang.classloader.loadclass(classloader.java:511)                                                                                        @ java.lang.classloader.loadclass(classloader.java:504)                                                                                                 ... 17 more                                                                                             suppressed: java.lang.classnotfoundexception: android.support.v4.content.contextcompat                                                                                        @ java.lang.class.classforname(native method) 

code (ugly hell, know):

(i've removed import things, cause of body limit characters won't let me post)

public class mainactivity extends activity {      bluetoothadapter bluetoothadapter;     listview listview;     arrayadapter<string> arrayadapter;       static final int permission_req_code = 1;     button pairbtn;     button discoverbtn;     togglebutton discovertoggle;     boolean isregistered;     boolean btexitsetting;     boolean insettings;     boolean serverlistening;      radiogroup radiogroup;     radiobutton receiveradiobtn;     radiobutton sendradiobtn;      edittext userinputfield;     string userinput = "";     string clientmsg;   //  button receivebtn = (button) findviewbyid(r.id.receivebtn);          @targetapi(build.version_codes.jelly_bean_mr2)     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.main_activity);          log.v("uuid",string.valueof(uuid.randomuuid()));          /* ___ setting bluetooth ___ */         // - bluetoothadapter -         bluetoothadapter = bluetoothadapter.getdefaultadapter();         ////bluetoothmanager bluetoothmanager = (bluetoothmanager)getsystemservice(bluetooth_service);         ////bluetoothadapter = bluetoothmanager.getadapter();          if (bluetoothadapter == null) {             // device not support bluetooth             toast nobt_toast = toast.maketext(this,"device not support bluetooth!",toast.length_short);             nobt_toast.show();         }          // - enable bluetooth -         if (!bluetoothadapter.isenabled()) {             intent enablebtintent = new intent(bluetoothadapter.action_request_enable);             startactivityforresult(enablebtintent, 0);         }           listview = (listview)findviewbyid(r.id.listview);         arrayadapter = new arrayadapter<string>(this,android.r.layout.simple_list_item_1);         listview.setadapter(arrayadapter);           // * of marshmallow, permissions not considered "normal" (dangerous - may expose user data), must granted user @ runtime.         // includes starting bluetooth discovery feature.          // request location permission (needed bluetooth) @ runtime:         requestpermission();           pairbtn = (button)findviewbyid(r.id.pairbtn);         pairbtn.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                 // ___ finding paired devices ___ //                 paireddevices();             }         });          discovertoggle = (togglebutton)findviewbyid(r.id.discovertoggle);         discovertoggle.setoncheckedchangelistener(new compoundbutton.oncheckedchangelistener() {             @override             public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) {                 if (ischecked) {                     discoverdevices();                 }                 else if (!ischecked) {                     disablediscovery();                 }             }         });           radiogroup = (radiogroup) findviewbyid(r.id.radiogroup);         receiveradiobtn = (radiobutton) findviewbyid(r.id.receiveradiobtn);         sendradiobtn = (radiobutton) findviewbyid(r.id.sendradiobtn);        //  userinputfield = (edittext) findviewbyid(r.id.userinputfield);     }          @override     public boolean oncreateoptionsmenu(menu menu) {         super.oncreateoptionsmenu(menu);          getmenuinflater().inflate(r.menu.menu_main, menu);          view view = menu.finditem(r.id.action_connect).getactionview();         switch connect_switch = (switch) view.findviewbyid(r.id.connect_switch);         connect_switch.setoncheckedchangelistener(new compoundbutton.oncheckedchangelistener() {             @override             public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) {                 acceptthread acceptthread = new acceptthread();                 if (ischecked) {                     log.d("switch", "checked");                         acceptthread.start();                 }                 else if (!ischecked) {                     log.d("switch", "!checked");                     acceptthread.closeconnection();                 }             }         });          return true;     }      @override     public boolean onoptionsitemselected(menuitem item) {         super.onoptionsitemselected(item);          if (item.getitemid() == r.id.action_settings) {             intent settingintent = new intent(this, settings.class);             startactivity(settingintent);              insettings = true;         }          if (item.getitemid() == r.id.action_exit) {             onstop();             finish();         }          return true;     }       @override     protected void onresume() {         super.onresume();          if (getintent().getextras() != null) {             sharedpreferences sharedpref = preferencemanager.getdefaultsharedpreferences(this);             btexitsetting = sharedpref.getboolean("pref_key_exit_bluetooth", false);             log.v("bundle", string.valueof(btexitsetting));              insettings = false;         }     }      @override     protected void onstop() {         super.onstop();         log.w("onstop", "invoked!");          disablediscovery();          if (btexitsetting && !insettings) {             bluetoothadapter.disable();         }      }      @override     protected void ondestroy() {         super.ondestroy();         log.w("ondestroy", "invoked!");     }       /* ___ finding paired devices ___ */     private void paireddevices() {         // - querying paired devices -         final set<bluetoothdevice> paireddevices = bluetoothadapter.getbondeddevices();         // if there paired devices         if (paireddevices.size() > 0) {             // loop through paired devices             (bluetoothdevice device : paireddevices) {                 // add name , address array adapter show in listview                 arrayadapter.add(device.getname() + "\n" + device.getaddress());             }         }     }       // - discovering devices -     // create broadcastreceiver action_found     private final broadcastreceiver broadcastreceiver = new broadcastreceiver() {         @override         public void onreceive(context context, intent intent) {              log.v("onreceive","invoked");              string action = intent.getaction();             // when discovery finds device             if (bluetoothdevice.action_found.equals(action)) {                  log.v("bt devices","found");                  // bluetoothdevice object intent                 bluetoothdevice device = intent.getparcelableextra(bluetoothdevice.extra_device);                 // add name , address array adapter show in listview                 arrayadapter.add(device.getname() + "\n" + device.getaddress());                 log.e("bt", device.getname() + "\n" + device.getaddress());                 arrayadapter.notifydatasetchanged();             }              else {                  log.v("bt devices","!!!found");              }              isregistered = true;          }     };       private void discoverdevices() {         // - enabling discoverability -         intent discoverableintent = new intent(bluetoothadapter.action_request_discoverable);         discoverableintent.putextra(bluetoothadapter.extra_discoverable_duration, 300);         startactivity(discoverableintent);          // register broadcastreceiver         intentfilter filter = new intentfilter(bluetoothdevice.action_found);         // * add following actions ensure start of bt dicovery mode.         filter.addaction(bluetoothadapter.action_discovery_finished);         filter.addaction(bluetoothadapter.action_discovery_started);         registerreceiver(broadcastreceiver, filter); // don't forget unregister during ondestroy          if (bluetoothadapter != null && bluetoothadapter.isdiscovering()) {             bluetoothadapter.canceldiscovery();         }          if (bluetoothadapter != null) {             log.e("adapter","not null!");         }          bluetoothadapter.startdiscovery();         if (bluetoothadapter.isdiscovering()) {             log.e("btadapter","discovering!");         }     }      private void disablediscovery() {         bluetoothadapter.canceldiscovery();         if (isregistered) {             unregisterreceiver(broadcastreceiver);         }     }       /* ___ accepting client connection. ___*/     private class acceptthread extends thread {          private final bluetoothserversocket mmserversocket;         connectedthread connectedthread;          public acceptthread() {             // use temporary object later assigned mmserversocket,             // because mmserversocket final             bluetoothserversocket tmp = null;             try {                 // my_uuid app's uuid string, used client code                 string name = "bluetoothserver";                 uuid my_uuid = uuid.fromstring("0ae3d869-470e-45d1-b147-a10882fc1bd2");                 tmp = bluetoothadapter.listenusingrfcommwithservicerecord(name, my_uuid);                  log.e("server", "listening");              }             catch (ioexception e) { }             mmserversocket = tmp;         }          public void run() {             bluetoothsocket socket = null;             // keep listening until exception occurs or socket returned             while (true) {                 try {                     socket = mmserversocket.accept();                      log.e("connection","accepted");                  } catch (ioexception e) {                     break;                 }                 // if connection accepted                 if (socket != null) {                      // work manage connection (in separate thread)                     connectedthread = new connectedthread(socket);                     connectedthread.start();                     cancel();                  }             }         }          /** cancel listening socket, , cause thread finish */         public void cancel() {             try {                 mmserversocket.close();             } catch (ioexception e) { }         }          public void closeconnection() {             if (connectedthread != null) {                 connectedthread.close();             }         }      }       /* managing connection */     private class connectedthread extends thread {         private final bluetoothsocket mmsocket;         private final inputstream mminstream;         private final outputstream mmoutstream;          bufferedreader inputstream;         printwriter outputstream;          public connectedthread(bluetoothsocket socket) {             mmsocket = socket;             inputstream tmpin = null;             outputstream tmpout = null;              // input , output streams, using temp objects because             // member streams final             try {                 tmpin = socket.getinputstream();                 tmpout = socket.getoutputstream();                  inputstream = new bufferedreader(new inputstreamreader(socket.getinputstream()));                 outputstream = new printwriter(socket.getoutputstream(), true);               } catch (ioexception e) { }              mminstream = tmpin;             mmoutstream = tmpout;         }             public void run() {                radiobutton rb = (radiobutton) findviewbyid(r.id.receiveradiobtn);             rb.setonclicklistener(new radiobutton.onclicklistener(){                 @override                 public void onclick(view v)                  /*{ synchro sync = new synchro();                     thread t = new thread(sync);                     t.start();}*/                 {                     for(int = 0; < 1000; i++) {                         read();                          textview clientmsgtxv = (textview) findviewbyid(r.id.clientmsgtxv);                         clientmsgtxv.settext(clientmsg);                         log.i("server msg", clientmsg);                     }                 }             });              final togglebutton receivebtn = (togglebutton) findviewbyid(r.id.receivebtn);             receivebtn.setonclicklistener(new togglebutton.onclicklistener(){                 @override                 public void onclick(view v) {                     while (true) {                         try {                             if (mminstream.available() > 0 ){                                 read();                                 textview clientmsgtxv = (textview) findviewbyid(r.id.clientmsgtxv);                                 clientmsgtxv.settext(clientmsg);                                 log.i("server msg", clientmsg);                             }                             else systemclock.sleep(100);                         }                         catch(ioexception io)                         {                             close();                             break;                         }                     }                     }             });         }           private void read() {             try {                  if(inputstream.ready()) {                     if ((clientmsg = inputstream.readline()) != null || !("".equals(clientmsg))) {                     } else {                         clientmsg = "empty";                     }                       log.i("server msg", clientmsg);                     log.v("inputstream", "read");                 }             } catch (ioexception e) {                 e.printstacktrace();             }         }          private void write() {             // ensure user input added output stream - add conditional statement check if userinput variable not null.             if (userinput != null) {                 log.e("user input", userinput);                 outputstream.println(userinput);                 log.d("output stream", "written client");             }         }          /* shutdown connection */         public void close() {             try {                 mmsocket.close();             } catch (ioexception e) { }         }     }         private void requestpermission() {         // here, current activity         if (contextcompat.checkselfpermission(this,                 manifest.permission.access_coarse_location)                 != packagemanager.permission_granted) {                  activitycompat.requestpermissions(this,                         new string[]{manifest.permission.access_coarse_location},                         permission_req_code);                  // permission_req_code app-defined int constant.                 // callback method gets result of request.         }     }      @override     public void onrequestpermissionsresult(int requestcode,     string permissions[], int[] grantresults) {         switch (requestcode) {             case permission_req_code: {                 // if request cancelled, result arrays empty.                 if (grantresults.length > 0                         && grantresults[0] == packagemanager.permission_granted) {                      // permission granted - bt-related task need do.                  } else {                      // permission denied - disable functionality depends on permission.                      string btpermissiondeniedstr = "sorry, bluetooth communication not possible without granting location permission";                     toast.maketext(this,btpermissiondeniedstr,toast.length_long).show();                  }                 return;             }         }     }      public void setretotext() {           textview clientmsgtxv = (textview) findviewbyid(r.id.clientmsgtxv);         clientmsgtxv.settext(clientmsg);         log.i("server msg", clientmsg);     }  } 

it seems you're missing support library. can post build.gradle file app module , project?


Comments