Flutter显示设备列表却无法运行,flutter doctor检测结果异常求助
Hey there, let's work through this tricky Flutter device detection issue on Ubuntu—this flakiness is definitely frustrating, but we can fix it with a few targeted steps:
1. Fix USB Permissions (The #1 Cause)
Linux systems often restrict USB access for non-root users, which makes Flutter flip-flop on device detection. Here's how to fix it:
- Create a udev rule file with sudo privileges:
sudo nano /etc/udev/rules.d/51-android.rules - Add this line (replace
your_usernamewith your actual Ubuntu username, and use your device's vendor ID fromlsusbif needed):SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", MODE="0666", OWNER="your_username" - Reload the udev rules and trigger changes:
sudo udevadm control --reload-rules && sudo udevadm trigger - Unplug your device, wait 5 seconds, then plug it back in. Run
flutter devicesto test.
2. Restart the Flutter Daemon
Sometimes the Flutter background daemon gets stuck in a broken state. Killing it forces a fresh start:
- Run this command to terminate the daemon:
flutter daemon --kill - Wait 10 seconds, then run
flutter devicesor check your IDEA device list again.
3. Update Flutter & Resolve Licenses
Outdated Flutter versions or missing Android licenses can cause unexpected stability issues:
- Grab the latest stable Flutter version:
flutter upgrade - Accept all required Android SDK licenses (this fixes hidden permission issues):
flutter doctor --android-licenses
4. Refresh IDEA's Flutter Plugin & Cache
IDEA's plugin can sometimes get out of sync with the Flutter daemon:
- Go to
Settings > Plugins, find the Flutter plugin, and click "Update" if an update is available. - After updating, restart IDEA and go to
File > Invalidate Caches... > Invalidate and Restartto clear any stale device data.
5. Test with a Clean Project
Occasionally, the issue is tied to your specific project's configuration. Let's rule that out:
- Create a new minimal Flutter project:
flutter create test_device_fix - Navigate into the project folder and try running it:
cd test_device_fix flutter run
If this works, the problem is likely in your original project's android/app/build.gradle or other config files.
6. Check Verbose Logs for Clues
If none of the above works, get verbose output from Flutter to see exactly what's going wrong:
- Run:
flutter devices -v
Look for lines about device connection failures or permission errors—this will point you to the exact issue.
内容的提问来源于stack exchange,提问作者Gaurav A Dubey

