title: A proper way to Debug a Service in Android Studio?
body: <p>Is there a proper way to debug a service in Android Studio? Or Android Studio could not do this? When I try to debug, it will just disconnects the sockets. ("Disconnected from the Target VM, address:'localhost:8600',transport 'socket')</p>
  
  <p>Hopefully you can assist me here.. </p>
  
  <p>What I have done as advice by some links here, I had place the .waitForDebugger but nothing happens. Please help me.. Thank you very much.</p>
  
  <pre><code>   @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      Intent mainService = new Intent(this,MainPowerAndVolumeService.class);
  
      startService(mainService);
      android.os.Debug.waitForDebugger();
  
      finish();
  
  }
  </code></pre>