Flutter或Visual Studio Code不可见的Android虚拟设备(但在Android Studio中可以) [英] Android Virtual Devices not visible to Flutter or Visual Studio Code (but ok in Android Studio )

查看:159
本文介绍了Flutter或Visual Studio Code不可见的Android虚拟设备(但在Android Studio中可以)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那里有很多类似的问题,但是它们都没有帮助(例如,此问题好评如潮,答案也不错,而且似乎是骗人的. BUT 而且答案是2岁,这是Flutter的永恒).

There are many similar questions out there, but none of them help (for instance, this question is well upvoted, with a well upvoted answer, and would seem to be a dupe. BUT like others who commented there, the answer did not help me (also, the answer is 2 years old, which is an eternity on Flutter)).

最多,他们讲述了如何在Android Studio中添加Android VM.我已经这样做了:

At most, they tell how to add an Android VM in Android Studio. I have done so:

他们还建议设置环境变量ANDROID_HOME和/或ANDROID_SDK_ROOT.我将两者设置为相同的值:

They also suggest setting the environment variables ANDROID_HOME and/or ANDROID_SDK_ROOT. I have set both to the same value:

C:\Users\me>dir %ANDROID_HOME%
 Volume in drive C is Windows
 Volume Serial Number is FE0C-16F0

 Directory of C:\Users\me\AppData\Local\Android\sdk

17/06/2020  12:18    <DIR>          .
17/06/2020  12:18    <DIR>          ..
19/06/2020  10:46    <DIR>          .downloadIntermediates
20/06/2020  07:22                16 .knownPackages
19/06/2020  10:47    <DIR>          .temp
14/06/2020  13:15    <DIR>          build-tools
17/06/2020  12:18    <DIR>          cmdline-tools
08/06/2020  13:53    <DIR>          emulator
08/06/2020  18:35    <DIR>          extras
16/06/2020  12:50    <DIR>          licenses
08/06/2020  13:53    <DIR>          patcher
19/06/2020  10:47    <DIR>          platform-tools
08/06/2020  19:21    <DIR>          platforms
16/06/2020  12:59    <DIR>          skins
08/06/2020  13:55    <DIR>          sources
14/06/2020  13:15    <DIR>          system-images
08/06/2020  13:54    <DIR>          tools
               1 File(s)             16 bytes
              16 Dir(s)  18,697,719,808 bytes free

C:\Users\me>

当我创建默认的Flutter应用时,Android Studio会向我显示VM作为运行/调试的选项:

When I create the default Flutter app, Android Studio shows me the VMs as an option for run/debug:

BUT ,当我使用Visual Studio Code打开同一项目的文件夹(或其他任何文件夹)并运行时,它会在Chrome浏览器中启动,因为:

BUT, when I open that same project's folder (or any other) with Visual Studio Code and run, it launches in the Chrome browser, because:

PS C:\Users\me\AndroidStudioProjects\flutter_app> flutter devices
3 connected devices:

Web Server • web-server • web-javascript • Flutter Tools
Chrome     • chrome     • web-javascript • Google Chrome 83.0.4103.106
Edge       • edge       • web-javascript • Microsoft Edge 83.0.478.54
PS C:\Users\me\AndroidStudioProjects\flutter_app> 

问题:Flutter如何识别我的Android虚拟机?

Question: how do get Flutter to recognize my Android virtual machines?

我可以看到每个文件在c:\Users\me\.android\avd中都有一个子目录.如何使Flutter意识到这一点?

I can see that each has a sub-directory in c:\Users\me\.android\avd. How do I make Flutter aware of it?

为完整起见,这是Flutter doctor的输出:

Here's the output of Flutter doctor, for completeness:

C:\Users\me>flutter doctor -v
[√] Flutter (Channel master, 1.20.0-1.0.pre.132, on Microsoft Windows [Version 10.0.18363.900], locale en-GB)
    • Flutter version 1.20.0-1.0.pre.132 at e:\coding\flutter
    • Framework revision 5995661777 (8 hours ago), 2020-06-19 16:15:58 -0700
    • Engine revision 676cd566f7
    • Dart version 2.9.0 (build 2.9.0-17.0.dev 7e72c9ae7e)


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at C:\Users\me\AppData\Local\Android\sdk
    • Platform android-R, build-tools 29.0.3
    • ANDROID_HOME = C:\Users\me\AppData\Local\Android\sdk
    • ANDROID_SDK_ROOT = C:\Users\me\AppData\Local\Android\sdk
    • Java binary at: E:\coding\Android_studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.0)
    • Android Studio at E:\coding\Android_studio
    • Flutter plugin version 46.0.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] Connected device (3 available)
    • Web Server • web-server • web-javascript • Flutter Tools
    • Chrome     • chrome     • web-javascript • Google Chrome 83.0.4103.106
    • Edge       • edge       • web-javascript • Microsoft Edge 83.0.478.54

• No issues found!

C:\Users\me>


[更新]现在,这很有趣:当我在Android Studio中运行Flutter应用时,其虚拟机突然在Flutter/Visual Studio代码中可见


[Update] Now, this is interesting: when I run a Flutter app in Android studio, its VM suddenly becomes visible in Flutter/Visual Studio Code

PS C:\ Users \ me \ AndroidStudioProjects \ flutter_app>抖动设备 4 连接的设备:

PS C:\Users\me\AndroidStudioProjects\flutter_app> flutter devices 4 connected devices:

sdk gphone x86支臂•模拟器-5554•android-x86•Android 11(API 30)(仿真器)Web服务器•Web服务器•Web Javascript•
Flutter Tools铬•镀铬•网络javascript•
Google Chrome 83.0.4103.106边缘•边缘•
网络JavaScript•Microsoft Edge 83.0.478.54 PS
C:\ Users \ me \ AndroidStudioProjects \ flutter_app>

sdk gphone x86 arm • emulator-5554 • android-x86 • Android 11 (API 30) (emulator) Web Server • web-server • web-javascript •
Flutter Tools Chrome • chrome • web-javascript •
Google Chrome 83.0.4103.106 Edge • edge •
web-javascript • Microsoft Edge 83.0.478.54 PS
C:\Users\me\AndroidStudioProjects\flutter_app>

当我在Android Studio中停止设备时,Flutter无法再看到它

When I stop the device in Android Studio, Flutter can no longer see it

推荐答案

我建议您重新安装所有废话

高度建议您使用git来安装flutter;然后在android studio中安装android SDK.不要忘记将flutter/bin添加到PATH.然后在Android Studio中创建您的虚拟设备,它应该显示在VS代码和控制台中.如果您仍然有问题,请在Twitter @colleettuserre上给我发消息,我将向您发送指向我的不和谐服务器的链接,以便我们深入了解此问题.

I would suggest you reinstall all of that crap

I highly suggest that you use git to install flutter; then install the android SDK with android studio. Don't forget to add flutter/bin to your PATH. Then create your Virtual Device in Android Studio and it should show up in VS code and the console. If you still have issues, please dm me on twitter @colleettuserre and I'll send you a link to my discord server so we can get to the bottom of this.

这篇关于Flutter或Visual Studio Code不可见的Android虚拟设备(但在Android Studio中可以)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆