0

While testing Flutter apps on a connected (by USB) Android (Samsung S5, running API 23) device using:

Android Studio 20201.3.1 Patch 3 Mac OS Monterey

The app will run on the device the first time, but subsequent attempts result in the run tab saying:

Error connecting to the service protocol: failed to connect to http://127.0.0.1...

The only way I can solve it is by restarting the device (the phone).

There must be a better way than restarting the device every time I test/build.

Does anyone know the cause and/or solution to this?

Nerdy Bunz
  • 6,040
  • 10
  • 41
  • 100

1 Answers1

0

A workaround is:

While the project is open in Android Studio as a Flutter project,

Navigate to MainActivity in the Android\app\src... folder

Select "Open for editting in Android Studio" at the top-right of the screen.

Then when the project is open "as an Android project" you can run it however many times you want. (Flutter is no longer involved).

Nerdy Bunz
  • 6,040
  • 10
  • 41
  • 100