Android studio - flutter: No Connected Devices

痴心易碎 提交于 2021-01-29 05:28:41

问题


I have just started with mobile development using flutter, and there is this error when trying to run the default flutter program.

No connected devices found; please connect a device, or see flutter.dev/setup for getting started instructions.

  • This is a Windows 10 x64 machine.

  • Installed Android Studio in - D:\Program Files\Android\Android Studio1

  • Installed Android SDK from Android Studio in - D:\Android\android-sdk

  • Set these system environment variables

    ANDROID_HOME - D:\Android\android-sdk;D:\Android\android-sdk\tools;D:\Android\android-sdk\build-tools;D:\Android\android-sdk\platform-tools

    ANDROID_SDK_ROOT - D:\Android\android-sdk;D:\Android\android-sdk\tools;D:\Android\android-sdk\build-tools;D:\Android\android-sdk\platform-tools

  • Installed Nexus 6 API 28 device & set Emulated Performance Graphics to Hardware GLES-2.0

  • Installed pie Android 9.0 x86 & pie Android 9.0 x86_64 as I was unsure which one to use. The AVD emulator launches fine with both the OS. (Which one to use?)

  • Installed flutter in - D:\Flutter\flutter

When I run main.dart, it shows this error:

When I run flutter doctor in the Android Studio it shows 2 issues:

[X] Android toolchain - develop for Android devices
    X ANDROID_HOME = D:/Android/android-sdk
      but Android SDK not found at this location.
[!] Connected device
    ! No devices available

When I try to run a command in powershell from the flutter directory, it gives this error:


回答1:


In environment variables > User Variables, add a new PATH, like: C:\src\flutter\bin

Then restart your machine.




回答2:


I think the error in the powershell means you did not add the Flutter SDK to your PATH as stated in the install documentation.

First follow the install documentation to add the Flutter SDK to your PATH, then close any PowerShell windows you have.

Open an emulator.

Open a PowerShell window.

Try to create a test project via the PowerShell like so

flutter create <project name>
cd <project name>
flutter run



回答3:


I was able to solve this with @rgvi solution.

  1. Added new path to PATH variable - D:\Flutter\flutter\bin
  2. Executed the command flutter doctor. This now showed that Android licenses status unknown.
  3. Executed the command flutter doctor --android-licenses and accepted the licenses.


来源:https://stackoverflow.com/questions/62991298/android-studio-flutter-no-connected-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!