On running default app, Flutter throws "log reader stopped unexpectedly" after switching to Master

Viewed 25504
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.

24 Answers

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

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

This worked for me.

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.

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.

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.

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.

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"

Simple Steps:

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

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.

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.

Clean your mobile cache then re-run the app

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

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

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.

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.

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.

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

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.

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

I have tried so many things to fix that problem. But at last, I fixed the it.

Just follow 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 .".

I think then you can continue using flutter.

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

This should work

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

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

I am having a similar issue. the problem here seems to be with the android sdk tools.

Previously, it would never debug at one go but it would run properly when i tried to debug it the second time. but thats not the case now.

Related