How to set up devices for VS Code for a Flutter emulator

前端 未结 16 729
南笙
南笙 2020-12-23 14:42

I\'d like to use VS Code as my editor for Flutter development, but I don\'t know how to get the emulator going. I\'ve installed VS Code on Ubuntu 17.10.

I followed th

相关标签:
16条回答
  • 2020-12-23 15:13

    For me, when I was running "flutter doctor" command from Ubuntu Command line - It showed me below error.

    [✗] Android toolchain - develop for Android devices ✗ Unable to locate Android SDK.

    From this error, it is obvious that "flutter doctor" was not able to find the "android sdk" and the reason for that was my android sdk was downloaded in a custom location on my Ubuntu machine.

    So we must need to tell "flutter doctor" about this custom android location, using below command,

    flutter config --android-sdk /home/myhome/Downloads/softwares/android-sdk/
    

    Need to replace /home/myhome/Downloads/softwares/android-sdk/ with path to your custom location/place where android sdk is available.

    Once this is done, and re-run "flutter doctor" and now it has detected the android sdk location and hence I could run avd/emulator by typing "flutter run"

    0 讨论(0)
  • 2020-12-23 15:15

    You do not need Android Studio to create or run a Virtual Device. Just use sdkmanager and avdmanager from the android sdk tools.

    Use the sdkmanager to download a system image of Android for x86 system.
    e.g. sdkmanager "system-images;android-21;default;x86_64"

    Then create a new virtual device using avdmanager.
    e.g. avdmanager create avd --name AndroidDevice01 --package "system-images;android-21;default;x86_64"

    Then run the new virtual device using emulator. If you don't have it just install it using the sdkmanager.
    e.g. emulator -avd AndroidDevice01

    If you restart VSCode and load your Flutter project. The new device should show up at the bottom right of the footer.

    0 讨论(0)
  • 2020-12-23 15:18

    VS Code needs to know where Android SDK is installed on your system. On Windows, set "ANDROID_SDK_ROOT" environment variable to the Android SDK root folder.

    Plus: Always check the "OUTPUT" and "DEBUG CONSOLE" tabs for errors and information.

    0 讨论(0)
  • 2020-12-23 15:19

    You do not need to create a virtual device using android studio. You can use your android device running on android 8.0 or higher. All you have to do is to activate developer settings, then enable USB DEBUGGING in the developer settings. Your device will show at the bottom right side of the VS Code. Without enabling the USB debugging, the device may not show.enter image description here

    0 讨论(0)
提交回复
热议问题