25
PS D:\flutterApp\myapp> flutter run
Running Gradle task 'assembleDebug'...

Running Gradle task 'assembleDebug'... Done                       203.1s (!)
√ Built build\app\outputs\apk\debug\app-debug.apk.
Installing build\app\outputs\apk\app.apk...                         7.7s
Error waiting for a debug connection: The log reader stopped unexpectedly
Error launching application on Redmi Note 4.

Earlier it was Error waiting for a debug connection: Bad state: No element, I switched to master from stable and now it is throwing this error on run. App is getting installed but crashing by throwing this error.

Bernard Vander Beken
  • 4,848
  • 5
  • 54
  • 76
Ajay Tom George
  • 1,890
  • 1
  • 14
  • 26

28 Answers28

22

You need to execute flutter clean command in your project and also make sure the device properly connected, the cable is attached properly. Also, you have to allow permission to launch on an app device and you should see a dialog while launching the app and restart the device...

$ flutter clean
Ali Fitroni
  • 237
  • 2
  • 2
15

Follow these simple steps

  1. Disconnect your device
  2. Clear Cache data of your device(Mobile)'s File Manager App
  3. Run flutter clean
  4. Connect your device and run the app
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Umang Donda
  • 151
  • 1
  • 3
9

I was facing the same issue, the problem occurred after I tried to change the package name of my flutter (Android App) may be from the old article. After reverting back the changes i.e setting default"com.example.app" as the package name issue disappears. If someone else is facing the issue, you can follow these two articles 1 or 2. In the first link, you might be having Points 1 & 2 a bit different you may not have any of these two:

File: MainActivity.java Path: /android/app/src/main/java/com/example/app Instead, you can have:

File: MainActivity.kt Path: /android/app/src/main/kotlin/com/example/app

so change accordingly.

Mayank chauhan
  • 378
  • 4
  • 10
  • 1
    This help me modify my app package since vscode doesn't update it like android studio. For future readers, after visiting article 2, you will find `CFBundleIdentifier` in iOS has a value of `$(PRODUCT_BUNDLE_IDENTIFIER)` so searching for this variable will lead to 3 places in `ios/Runner.xcodeproj/project.pbxproj` so modify those with your package name – joe_inz Jul 11 '21 at 09:43
7

For this error:

Error waiting for a debug connection: The log reader stopped unexpectedly 

try restarting the phone you are trying to run the application on, and make sure your USB debugging is enabled.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
4

Try :

flutter clean

and uninstall app from all user's from Settings > Apps > "Your App" > Click on top right 3 dots > "Uninstall From All Users"

Nishith Savla
  • 310
  • 2
  • 10
Mrudul Addipalli
  • 574
  • 6
  • 10
  • 1
    Thank you, this actually helped! In my case issue was that I uninstalled the app in personal profile and forgot to do it in work profile. – Art Feb 04 '22 at 08:34
3

The problem was happening to me when I was using the simulator. It was showing: "Error waiting for a debug connection: The log reader failed unexpectedly"

And the "Flutter Hot Reload" button was disabled.

Click on the "Futter Attach" button and the problem goes away when it connects to the device.

Hooman Malek
  • 499
  • 3
  • 11
  • Could you plz be more specific! Where is this "Flutter Attach" button? (It would really help speed up our trouble shooting.) – Karolina Hagegård Aug 01 '22 at 06:48
  • If using Visual Code, Shift+Command-P and search for the command to attach to the process called "Debug: Attach to Flutter on Device" in Visual Code. – qix Feb 11 '23 at 16:19
2

I also encountered the same issue and resolved it by enabling the file transfer option. There will be option to set for file transfer and you have enable it.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Aravind Siruvuru
  • 1,019
  • 12
  • 7
1

Simple Steps:

  1. Uninstall previous app already on your device
  2. Disconnect USB connection
  3. Run flutter clean
  4. Run your build again
yobo zorle
  • 348
  • 3
  • 8
1

On a Mac, I finally resolved this... or "resolved" this, by downloaded a new iOS simulator that works. :

  1. Open XCode
  2. Go to XCode > Preferences > Components, where there should be a list of downloadable simulators
  3. Click on the download symbol to the left of the simulator you want to download.

screenshot of downloading simulator

I'm suspecting the problem is related to my Mac not being very powerful...

Karolina Hagegård
  • 1,180
  • 5
  • 26
0

I have had the same problem for a whole week after upgrading to flutter 1.17....i did flutter clean and even downgraded to flutter 1.12 non of them worked...but when i upgraded my sdk tools(specifically flutter)the problem disappeared.

0

If you are on Mac, this might be because you don't have sudo access. I think the debugger needs to read iOS logs which requires sudo access. I was able to fix the issue by adding admin rights to my account (system preferences > User&Groups > Allow user to administer this computer). Of course, this might not be possible for everyone.

0

Clean your mobile cache then re-run the app

Bernard Vander Beken
  • 4,848
  • 5
  • 54
  • 76
Omar Essam El-Din
  • 1,415
  • 14
  • 17
0

I solved it by disabling USB-debugging and revoke permission then re enabled henceforth it seems okay.

A.K.J.94
  • 492
  • 6
  • 14
0

flutter clean probably works, but I also got it to work by

  1. Open Android Studio
  2. Run a project there on the connected device
  3. Stop debugging on Android Studio
  4. Run in VS Code again

This probably resets something similar to flutter clean

kilkfoe
  • 445
  • 5
  • 11
0

I have also encountered this error and I resolve this by going to my Phone's Settings and then in "Developer Option", there was an option "Select debug app" then choose your app from the list (if you are running multiple projects else there will be 1 app). Now your app will get debug access.

If you still have issues. You have to go to permission and allow access to the device storage, location, or any other if your app needs.

0

For Linux & Ubuntu Users

snap install flutter --classic
snap refresh flutter --channel candidate/20.04

As MarcusTomlinson have mentioned in Github issues

The overlying issue here is GL driver incompatibilities between snap and host.

Once I finally got this reproduced, looking at the journal I noticed flutter was crashing in the swrast GL driver. The issue here is that flutter is using GL drivers from within the snap rather than the host.

We had forced this in the past to work around VS Code setting LIBGL_DRIVERS_PATH to a path within its own snap. Looks like we should not have redirected that to the Flutter snap but rather to the host.

0

If this happens while launching a linux desktop build from the vscode debugger then it could be because you have both vscode and flutter installed as snaps. To solve, remove the vscode snap snap remove code and re-install it using another method such as downloading the .tar.gz and extracting it to a suitable directory. Your vscode settings and extensions will be preserved when you remove the snap.

Andy Brown
  • 11,766
  • 2
  • 42
  • 61
0

I solved this problem by following these steps:

  1. Open Android settings
  2. Go in AppList (in my case additional settings -> Applists)
  3. Find the app (Flutter which was previously installed)
  4. Clear all cache and data
  5. Uninstall this app
Nimantha
  • 6,405
  • 6
  • 28
  • 69
0

My current device is Redmi 9 prime

  • Android version: 11
  • MIUI version: 12.5.2

Even I faced a similar problem while debugging the app and then I disabled the USB debugging (security settings) and Revoke USB debugging authorizations in the developer option

The above method resolved my problem.

Bernard Vander Beken
  • 4,848
  • 5
  • 54
  • 76
0

This worked for me

  • Uninstall the application if it is installed
  • Flutter upgrade
  • Flutter clean
  • Flutter pub get
  • Change build gradle kotlin version "ext.kotlin_version = '1.6.10'"
  • Change build gradle sdk version "compileSdkVersion 31"
  • Android studio invalidate caches
0

I fixed that problem following those steps:

  1. Update flutter.
  2. Install the latest Windows 10 SDK (For me it was V-10.0.20348.0) from Visual Studio Installer > Modify > Desktop Development with C++ > Install Details > Optional. See image here:
  3. After installation launch the Visual studio community. (This is so much important to fully open the Visual studio community for the first time.) See image here:
  4. Then open your project with your favorite CODE EDITOR.
  5. Then from the terminal or cmd (cmd in the project directory) run flutter clean and then flutter create ..
desertnaut
  • 57,590
  • 26
  • 140
  • 166
0

You don't need to use flutter clean, as it will delete most dependencies on your application.

I simply solved the issue using the following steps:

  1. Uninstalling the current application on my phone.
  2. Restarting my phone
desertnaut
  • 57,590
  • 26
  • 140
  • 166
0

Disconnect your device Clear Cache data of your device(Mobile)'s File Manager App Run flutter clean Connect your device and run the app Restart your phone

Zia Ullah
  • 27
  • 5
0

The problem in my case was Dropbox trying to sync the files produced by the Build/Run. They somehow got locked for reading. I paused Dropbox syncing and it worked.

Gad D Lord
  • 6,620
  • 12
  • 60
  • 106
0

I tried everything in this thread in isolation and it didn't fix it for me (with simulator).

Got it to work with the following steps:

  1. flutter clean
  2. Simulator -> Device -> "Erase All Content and Settings..."
  3. Restart computer!!
  4. Launch simulator
  5. flutter clean (one more for good measure)
  6. Run the app
  7. Fixed
Kyle Venn
  • 4,597
  • 27
  • 41
0

Responding to "Error waiting for a debug connection: The log reader stopped unexpectedly" ... In the end I found that my code was not the cause of this error. I found that the error is confirming a communication issue between the Flutter Console and the current emulator. I found that when I switched between emulators, that another emulator didn't have the same error or issue and everything worked fine. So, my conclusion is that the error presents itself where there is a software flaw regarding the current emulator, which should mean that a software update or an alternative emulator is the way around the problem.

I trust that my contribution will help others to save time.

mathems32
  • 115
  • 9
0

in my case i run the flowing command to resolve this

flutter clean; flutter
0
  1. flutter clean
  2. remove .symlinks, pods, podfile.lock in ios directory
  3. Clean XCode caches: System Settings -> General -> Developer
  4. Pod install in ios directory
  5. Reboot your system
  6. Magic happened (as for me).
Mykola Meshkov
  • 126
  • 1
  • 4