Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter application throws Http Exception and instantly crashes

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"))),
    );
  }
}
like image 484
Patrick Visi Avatar asked Mar 11 '19 08:03

Patrick Visi


3 Answers

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

like image 88
Marcelo Gouveia Avatar answered Oct 24 '22 00:10

Marcelo Gouveia


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

like image 1
Shiva Pandey Avatar answered Oct 23 '22 22:10

Shiva Pandey


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

like image 1
Renan Avatar answered Oct 23 '22 22:10

Renan