我尝试让 android studio(模拟器)与 vs-code 一起工作,但出现错误“Android SDK 中缺少 avdmanager”

这是我的路径

export ANDROID_SDK_ROOT=/mnt/sda1/DevTools/sdk/
export ANDROID_HOME=$ANDROID_SDK_ROOT
export PATH=${PATH}:/mnt/sda1/DevTools/sdk/platform-tools

enter image description here

我尝试了很多情况,但仍然是这个错误!

stack overflow I try to make android studio (emulator) work with vs-code but have an error "avdmanager is missing from the Android SDK"
原文答案

答案:

作者头像

Try :

flutter doctor --android-licenses

if something wrong, try to locate android sdk path.

flutter config --android-sdk {path}

Mine :

flutter config --android-sdk C:\Android\Sdk
作者头像

This worked for me. If you have sdkmanager, avdmanager and emulator, and you have them in your PATH environmental variable, then

  1. Download a system image:

sdkmanager "system-images;android-30;google_apis_playstore;x86_64"

(you can find available packages with sdkmanager --list --verbose)

  1. Create a new virtual device with

avdmanager create avd --name MyAndroidDevice --package "system-images;android-30;google_apis_playstore;x86_64"

  1. Start the emulator

emulator -avd MyAndroidDevice

  1. Now restart VSCode and open your Flutter project. The new device should be at the bottom right corner or you should be able to choose it by clicking on "No device".
作者头像

I know this is an old question but setting my $PATH variable in ~/.bashrc (I'm on Ubuntu 20.04) did not work for me.

I needed to setup Android Emulator for VScode, because I wanted to run my flutter app, which seems to be the same issue as OP had.

Instead of setting the $PATH directly you can actually use Flutter in the terminal to do it.

If you run "flutter config" in the terminal you get something like:


Configure Flutter settings.

To remove a setting, configure it to an empty string.

The Flutter tool anonymously reports feature usage statistics and basic crash reports to help improve Flutter tools over time. See Google's privacy policy: https://www.google.com/intl/en/policies/privacy/

....

Run "flutter help" to see global options.

Settings: android-sdk: <my_path_to_android_tools>

Analytics reporting is currently enabled.


You can then see the $PATH that is currently set with flutter under:

Settings: android-sdk: <my_path_to_android_tools>

Mine was incorrect so I changed it to the current one with the command:

flutter config --android-sdk <my_path_to_android_tools>

Afterwards I restarted VScode and when it was finished loading I could now press the "device" button in the right hand corner and then select emulator that I had already created. I used one of the above answers to install the emulator itself.

It took a while to launch the emulator the first time due to installing some dependencies but it did work!

作者头像

I tried this and works:

  • from terminal run flutter config --enable-android. You will get Setting "enable-android" value to "true".
  • after that open android studio, set up virtual devices first if you haven't. Open Android Studio -> Configure -> AVD Manager -> Create Your Virtual Device
  • Go back to your VS Code, open command Palette (Ctrl+P or cmd+P, then type >), or from View -> Command palette... -> Flutter: Select Device -> choose your android device
作者头像

我遇到了同样的问题,并在 VS Code 中从终端运行 flutter doctor 解决了它。就我而言,我将 android sdk 位于自定义位置(D 驱动器),这就是它没有自动找到的原因。 “医生”告诉我运行 flutter config --android-sdk <my-sdk-custom-location> 。运行它并重新启动 IDE 就成功了。希望这可以帮助面临同样问题的人。