You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Help new developers get a Flutter-compatible android emulator AVD created #13379
The -d is the device, and we can get a full list of them by running avdmanager list device -c, which gives output like this (yeah, that first line really is a ton of junk on one line, despite us passing -c which is compact output for scripts?!):
The other argument (-k) is a bit weird. If we don't provide it we get output like this:
Error: Package path (-k) not specified. Valid system image paths are:
system-images;android-27;google_apis;x86
system-images;android-P;google_apis;x86
system-images;android-27;google_apis_playstore;x86
null
I'm not sure why null is there when apparently I have to specify it... I can't figure out a way to get this list other than calling create with invalid values. We can run avdmanager list targets but that only gives us android-27!
So, for devices we could let the user select, or we could just have a list of our preferences (eg. starting with something like Nexus 5) and use the first one we find that's valid when running avdmanager list device).
For the -k, I think we'd need to do avdmanager list target and then pick the "best" one from that list (possibly android-{x} with {x} being the highest number?) and then we'd have to run create to get a list of all the valid targets and filter it to those that contain the target we have.
For my MacBook, that would leave us with these to pick from:
From there I suggest we decide whether google_apis or google_apis_playstore is best, and then just pick the best match out of what's left. If there are no matches, we just tell the user we failed. If we get an error when then issuing the create, we just route it back to the user.
Honestly i've been using flutter on iOS and iOS simulator for a couple months, and I still can't figure out how to make my Android Simulator with VS Code.
@JosephDunivan You should be able to both create and launch Android emulators from VS Code. If you click on the Device name in the status bar (or "No Devices" if you don't have one active) you should get a dropdown that lets you select a device - the bottom option should create an emulator (which will then show in the list next time).
Honestly its part of a much larger issue related to the depreciated ANDROID-HOME path issue. I had to install brew cask android-sdk, then delete it, then preform flutter config --android-sdk and point it to the path installed by android studio. Finally I had to create a dummy application in android sdk to open the avd and add a device. Afterwards I needed to restart VS Code. I think the process could be made simpler.
@JosephDunivan I think for many people the process is fairly simple (for me, it was as simple as just choosing the Create Emulator option!), I don't think they've all had to go through what you have. If you're able to give more details on what happened or how we may be able to reproduce it, it'd definitely be good to understand what what went wrong and fix it.
I'm curious why you installed the android-sdk via brew and it didn't install with Android Studio?
I specifically had to install both and then delete the brew install one. The reason is because the pointer path installed by flutter to /usr/local/share/android-sdk is depreciated. Android studio has installed it to the path $HOME/Library/Android/SDK for a couple years now. Changing the path in .bash_profile does not change the requirement imposed by flutter for the file to be located at /usr/local/share/android-sdk. Therefore flutter config had to be used. I followed the setup instructions from flutter to a "T" and these were still the hoops I had to jump through.
These were my final print outs from flutter doctor, but again I had to use flutter config to reroute the ANROID_HOME to Users/josephdunivan/Library/Android/sdk
[✓] Flutter (Channel beta, v1.0.0, on Mac OS X 10.14.2 18C52a, locale en-US)
• Flutter version 1.0.0 at /Users/josephdunivan/library/development/flutter
• Framework revision 5391447fae (6 days ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at /Users/josephdunivan/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /usr/local/share/android-sdk
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1136-b06)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.1, Build version 10B61
• ios-deploy 1.9.4
• CocoaPods version 1.5.3
[✓] Android Studio (version 3.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 31.1.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1136-b06)
[✓] VS Code (version 1.25.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 2.21.0
Looks like I've also set ANDROID_HOME to ~/Library/Android/sdk in my .bash_profile so that Flutter can find it, but I haven't done anything else. Do you remember exactly what didn't work for you after installing Android Studio if you just set ANDROID_HOME?
Just no matter how many different ways I tried to redirect my path in my bash_profile, whenever I ran flutter doctor -v it just had no effect.
what I have in my path right now(but I attempted many many different versions of importing the paths):
If you wouldn't mind unsetting config and opening a new issue with the output from echo $ANDROID_HOME && flutter doctor -v if it's not working as you'd expect, I wouldn't mind trying to understand what went wrong.
(That said, I'm still unsure why you needed to install the SDK via brew - if setting the SDK path in Flutter config worked, doesn't that work with the Android Studio-installed version of the SDK?)
I'm scared to do that(after getting it work finally) but I suppose I could since it could help others.
As far as installing the sdk via brew:
I followed an article which instructed to try this and then perform an uninstall. I was able to catch that my java version was out of date. It's possible this step was completely unnecessary.
Tons of people are actually having the same issue as me over at #15114 .
Looks like everyone had to follow the flutter config fix.
I'm also still getting a PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value error when attempting to make a new Android Simulator in VS Code. That's why I set up a dummy flutter application via avd in Android Studio.
I followed an article which instructed to try this and then perform an uninstall. I was able to catch that my java version was out of date. It's possible this step was completely unnecessary.
Gotcha :) I do think that was unnecessary if you've installed Android Studio - if that turns out not to be the case it's definitely something we should look at.
Tons of people are actually having the same issue as me over at #15114 .
At least some of those people are trying to use Flutter without installing Android Studio. That's definitely a little more complicated today (though I hope this will improve in time, it's definitely a bit weird to install Android Studio if you want to use VS Code).
I'm happy to help troubleshoot if someone has installed Android Studio and set ANDROID_HOME (or used flutter config to set the path) and has complaints from flutter doctor. If you can repro either of those, feel free to open an new issue or post in the one linked above and ping me.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
sethladd commentedon Dec 6, 2017
I worked out the steps to create a new emulator from the CLI here: #9862 (comment)
(this assumes you have Android SDK already installed)
mit-mit commentedon Dec 7, 2017
Great, I added that bug to the list above and closed it to that we can use this to track the change going forward.
mit-mit commentedon Apr 6, 2018
I'd like to keep this in milestone 3. @DanTup is investigating, I believe
Add basic support for listing Android AVDs
Add basic support for listing Android AVDs
Add emulator.getEmulators and emulator.launch to daemon (#17466)
DanTup commentedon Jun 5, 2018
Ok, looked into creation a little more. Here's what I've found...
We can create an emulator like this:
The
-dis the device, and we can get a full list of them by runningavdmanager list device -c, which gives output like this (yeah, that first line really is a ton of junk on one line, despite us passing-cwhich is compact output for scripts?!):The other argument (
-k) is a bit weird. If we don't provide it we get output like this:I'm not sure why
nullis there when apparently I have to specify it... I can't figure out a way to get this list other than calling create with invalid values. We can runavdmanager list targetsbut that only gives usandroid-27!So, for devices we could let the user select, or we could just have a list of our preferences (eg. starting with something like
Nexus 5) and use the first one we find that's valid when runningavdmanager list device).For the
-k, I think we'd need to doavdmanager list targetand then pick the "best" one from that list (possiblyandroid-{x}with{x}being the highest number?) and then we'd have to runcreateto get a list of all the valid targets and filter it to those that contain the target we have.For my MacBook, that would leave us with these to pick from:
From there I suggest we decide whether
google_apisorgoogle_apis_playstoreis best, and then just pick the best match out of what's left. If there are no matches, we just tell the user we failed. If we get an error when then issuing the create, we just route it back to the user.WDYT @mit-mit @devoncarew?
mit-mit commentedon Jun 6, 2018
I'd say we just pick a Pixel image. We want the one that has playstore APIs for best compatibility.
DanTup commentedon Jun 6, 2018
Got a basic version of this working, looking for feedback: #18235
4 remaining items
DanTup commentedon Jul 30, 2018
@mit-mit @devoncarew Should we consider this done, or do we want to update IntelliJ with any of this?
devoncarew commentedon Aug 20, 2018
I think we can close this issue, and open a more IntelliJ specific issue.
JosephDunivan commentedon Dec 5, 2018
Honestly i've been using flutter on iOS and iOS simulator for a couple months, and I still can't figure out how to make my Android Simulator with VS Code.
DanTup commentedon Dec 5, 2018
@JosephDunivan You should be able to both create and launch Android emulators from VS Code. If you click on the Device name in the status bar (or "No Devices" if you don't have one active) you should get a dropdown that lets you select a device - the bottom option should create an emulator (which will then show in the list next time).
If you're having issues with this, please open an issue at https://github.com/Dart-Code/Dart-Code/issues/new with screenshots/errors and we'll figure out what's up.
JosephDunivan commentedon Dec 5, 2018
Honestly its part of a much larger issue related to the depreciated ANDROID-HOME path issue. I had to install brew cask android-sdk, then delete it, then preform flutter config --android-sdk and point it to the path installed by android studio. Finally I had to create a dummy application in android sdk to open the avd and add a device. Afterwards I needed to restart VS Code. I think the process could be made simpler.
DanTup commentedon Dec 5, 2018
@JosephDunivan I think for many people the process is fairly simple (for me, it was as simple as just choosing the Create Emulator option!), I don't think they've all had to go through what you have. If you're able to give more details on what happened or how we may be able to reproduce it, it'd definitely be good to understand what what went wrong and fix it.
I'm curious why you installed the android-sdk via brew and it didn't install with Android Studio?
JosephDunivan commentedon Dec 5, 2018
I specifically had to install both and then delete the brew install one. The reason is because the pointer path installed by flutter to
/usr/local/share/android-sdkis depreciated. Android studio has installed it to the path$HOME/Library/Android/SDKfor a couple years now. Changing the path in.bash_profiledoes not change the requirement imposed by flutter for the file to be located at/usr/local/share/android-sdk. Therefore flutter config had to be used. I followed the setup instructions from flutter to a "T" and these were still the hoops I had to jump through.These were my final print outs from flutter doctor, but again I had to use flutter config to reroute the ANROID_HOME to
Users/josephdunivan/Library/Android/sdkDanTup commentedon Dec 5, 2018
Looks like I've also set
ANDROID_HOMEto~/Library/Android/sdkin my.bash_profileso that Flutter can find it, but I haven't done anything else. Do you remember exactly what didn't work for you after installing Android Studio if you just setANDROID_HOME?JosephDunivan commentedon Dec 5, 2018
Just no matter how many different ways I tried to redirect my path in my bash_profile, whenever I ran flutter doctor -v it just had no effect.
what I have in my path right now(but I attempted many many different versions of importing the paths):
But still I had to run flutter config.
DanTup commentedon Dec 5, 2018
If you wouldn't mind unsetting config and opening a new issue with the output from
echo $ANDROID_HOME && flutter doctor -vif it's not working as you'd expect, I wouldn't mind trying to understand what went wrong.(That said, I'm still unsure why you needed to install the SDK via brew - if setting the SDK path in Flutter config worked, doesn't that work with the Android Studio-installed version of the SDK?)
JosephDunivan commentedon Dec 5, 2018
I'm scared to do that(after getting it work finally) but I suppose I could since it could help others.
As far as installing the sdk via brew:
I followed an article which instructed to try this and then perform an uninstall. I was able to catch that my java version was out of date. It's possible this step was completely unnecessary.
Tons of people are actually having the same issue as me over at #15114 .
Looks like everyone had to follow the
flutter configfix.I'm also still getting a
PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT valueerror when attempting to make a new Android Simulator inVS Code. That's why I set up a dummy flutter application via avd inAndroid Studio.DanTup commentedon Dec 5, 2018
Gotcha :) I do think that was unnecessary if you've installed Android Studio - if that turns out not to be the case it's definitely something we should look at.
At least some of those people are trying to use Flutter without installing Android Studio. That's definitely a little more complicated today (though I hope this will improve in time, it's definitely a bit weird to install Android Studio if you want to use VS Code).
I'm happy to help troubleshoot if someone has installed Android Studio and set
ANDROID_HOME(or usedflutter configto set the path) and has complaints fromflutter doctor. If you can repro either of those, feel free to open an new issue or post in the one linked above and ping me.github-actions commentedon Aug 16, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.