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"))),
    );
  }
}
6
  • Are you using a proxy in your network? Commented Mar 11, 2019 at 8:39
  • I think you should post the whole code to let us understand where the error is! Commented Mar 11, 2019 at 9:03
  • I posted code, and as you can see, it's very-very simple. I don't use http anywhere, btw, this error happens every time, it doesn't matter what the code is Commented Mar 11, 2019 at 9:20
  • I solved it by setting a mobile device and laptop on the same wifi network. Sometimes I need to restart the mobile device. Commented Mar 11, 2019 at 9:42
  • I have already tried these. None of them solve the problem Commented Mar 11, 2019 at 13:34

3 Answers 3

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).

Sign up to request clarification or add additional context in comments.

3 Comments

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 Did you try API version 28? Curious if that works for you.
@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.
1

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

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.