5

currently I'm having a problem with running flutter applications. I tried to search solutions, but none of them was actually my case. The problem is, when I try to install an application, sometimes it starts running, but instantly crashes, or not even build, and throws this exception (even with flutter demo project):

Error connecting to the service protocol: HttpException: Connection closed before full header was received, uri = http://127.0.0.1:57564/ws". 

What I've tried so far: Cleaning cashes, reinstall flutter/android studio. I got this problem only with a few (android os) mobile. import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(appBar: AppBar(title: Text("App"))),
    );
  }
}
Patrick Visi
  • 100
  • 1
  • 7

3 Answers3

6

I solved this problem creating a new emulator device but NOT using the most recent Android Image.

Android Studio > Configure > AVD Manager > Create Virtual Device > (Choose a device model) > (Select a system image, but NOT the most recent)

In my case, I had the following Android images as choices: Q, Pie 28, Oreo 27 and 26, etc. I selected Pie 28 and the problem was solved. The problem was occuring with Android Q (most recent).

  • 1
    I don't think this fixed it. I'm not on Android Q and I have this problem too and creating a new virtual device didn't fix it for me. – Loolooii Jun 01 '19 at 22:17
  • @Loolooii Did you try API version 28? Curious if that works for you. – dustinrwh Jun 14 '19 at 21:26
  • @dustinrwh This problem went away when I removed one of the plugins I was using. I just tried removing them one by one. Specifically it was `flutter_webview_plugin` causing this problem apparently. I'm not sure if your issue is also caused by something like this. – Loolooii Jun 16 '19 at 20:22
1

The problem is with the API version. Choose 28 It fixes the problem.

Shiva Pandey
  • 645
  • 6
  • 17
1

I use a real device and my problem was only solved when I deleted a plugin from pubspec.yaml file. Maybe this can help.

zeroDivider
  • 1,050
  • 13
  • 29
Renan
  • 11
  • 1