title: Flutter stuck at 'waiting for observatory port to be available' if Android background services is used
body: <p>I been trying to get write platform code for Flutter to get a background service started. In here, I used a minimal example with no <em>actual</em> work done to show that the application simply won't run. The actual flutter code is not modified at all.</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends FlutterActivity {
  
    Intent i = new Intent(this, MainService.class);
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      GeneratedPluginRegistrant.registerWith(this);
    }
  }
  </code></pre>
  
  <p><strong>MainService.java</strong></p>
  
  <pre><code>public class MainService extends IntentService {
    public MainService() {
      super("MainService");
    }
  
    @Override
    protected void onHandleIntent(Intent Intent) {
    }
  }
  </code></pre>
  
  <p><strong>AndroidManifest.xml</strong></p>
  
  <pre><code> &lt;service android:enabled="true"
  android:name=".MainService"&gt;&lt;/service&gt;
  </code></pre>
  
  <p>The buildVersion is >27 and Manifest file has the <code>service</code> tag added accordingly.</p>
  
  <p>Compiling and running with <code>flutter run -v</code> will show the following message:</p>
  
  <pre><code>..
  [ +121 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.example.hello/.MainActivity (has extras)}
  [   +1 ms] Waiting for observatory port to be available...
  </code></pre>
  
  <p>And the installation is stuck.</p>
  
  <p>Is there a workaround about this? If this is an actual bug in Flutter's implementation, does it also mean there is <strong>no</strong> way to run a Flutter application in the background?</p>