You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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:

Troubleshooting Flutter Device Detection Flakiness on Ubuntu

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_username with your actual Ubuntu username, and use your device's vendor ID from lsusb if 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 devices to 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 devices or 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 Restart to 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:15:35