Skip to content

Help new developers get a Flutter-compatible android emulator AVD created #13379

Closed

Description

@mit-mit

New users frequently struggle with getting a working emulator AVD configured for flutter. Sample issues:

#12428
#12353
#11493
#6728
#13118
#9862

This tracks a feature request to have us to ensure an appropriate configured AVD is created during the installation of Flutter.

Activity

  1. added this to the 3: Current Milestone milestone on Dec 6, 2017
  2. sethladd commented on Dec 6, 2017

    @sethladd
    Contributor

    I worked out the steps to create a new emulator from the CLI here: #9862 (comment)

    (this assumes you have Android SDK already installed)

  3. mit-mit commented on Dec 7, 2017

    @mit-mit
    MemberAuthor

    Great, I added that bug to the list above and closed it to that we can use this to track the change going forward.

  4. mit-mit commented on Apr 6, 2018

    @mit-mit
    MemberAuthor

    I'd like to keep this in milestone 3. @DanTup is investigating, I believe

  5. modified the milestones: 3: Current Milestone, on Apr 17, 2018
  6. DanTup commented on Jun 5, 2018

    @DanTup
    Contributor

    Ok, looked into creation a little more. Here's what I've found...

    We can create an emulator like this:

     avdmanager create avd -n "FlutterEmulator" -k "system-images;android-27;google_apis;x86" -d "Nexus 5"
    

    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?!):

    Parsing /Users/dantup/Library/Android/sdk/build-tools/26.0.2/package.xmlParsing /Users/dantup/Library/Android/sdk/build-tools/27.0.3/package.xmlParsing /Users/dantup/Library/Android/sdk/emulator/package.xmlParsing /Users/dantup/Library/Android/sdk/extras/android/m2repository/package.xmlParsing /Users/dantup/Library/Android/sdk/extras/google/m2repository/package.xmlParsing /Users/dantup/Library/Android/sdk/extras/intel/Hardware_Accelerated_Execution_Manager/package.xmlParsing /Users/dantup/Library/Android/sdk/extras/m2repository/com/android/support/constraint/constraint-layout-solver/1.0.2/package.xmlParsing /Users/dantup/Library/Android/sdk/extras/m2repository/com/android/support/constraint/constraint-layout/1.0.2/package.xmlParsing /Users/dantup/Library/Android/sdk/patcher/v4/package.xmlParsing /Users/dantup/Library/Android/sdk/platform-tools/package.xmlParsing /Users/dantup/Library/Android/sdk/platforms/android-27/package.xmlParsing /Users/dantup/Library/Android/sdk/sources/android-27/package.xmlParsing /Users/dantup/Library/Android/sdk/system-images/android-27/google_apis/x86/package.xmlParsing /Users/dantup/Library/Android/sdk/system-images/android-27/google_apis_playstore/x86/package.xmlParsing /Users/dantup/Library/Android/sdk/system-images/android-P/google_apis/x86/package.xmlParsing /Users/dantup/Library/Android/sdk/tools/package.xmlParsing /Users/dantup/Library/Android/sdk/build-tools/26.0.2/package.xmlParsing /Users/dantup/Library/Android/sdk/build-tools/27.0.3/package.xmlParsing /Users/dantup/Library/Android/sdk/emulator/package.xmlParsing /Users/dantup/Library/Android/sdk/extras/android/m2repository/package.xmlParsing /Users/dantup/Library/Android/sdk/extras/google/m2repository/package.xmlParsing /Users/dantup/Library/Android/sdk/extras/intel/Hardware_Accelerated_Execution_Manager/package.xmlParsing /Users/dantup/Library/Android/sdk/extras/m2repository/com/android/support/constraint/constraint-layout-solver/1.0.2/package.xmlParsing /Users/dantup/Library/Android/sdk/extras/m2repository/com/android/support/constraint/constraint-layout/1.0.2/package.xmlParsing /Users/dantup/Library/Android/sdk/patcher/v4/package.xmlParsing /Users/dantup/Library/Android/sdk/platform-tools/package.xmlParsing /Users/dantup/Library/Android/sdk/platforms/android-27/package.xmlParsing /Users/dantup/Library/Android/sdk/sources/android-27/package.xmlParsing /Users/dantup/Library/Android/sdk/system-images/android-27/google_apis/x86/package.xmlParsing /Users/dantup/Library/Android/sdk/system-images/android-27/google_apis_playstore/x86/package.xmlParsing /Users/dantup/Library/Android/sdk/system-images/android-P/google_apis/x86/package.xmlParsing /Users/dantup/Library/Android/sdk/tools/package.xmltv_1080p
    tv_720p
    wear_round
    wear_round_chin_320_290
    wear_square
    Galaxy Nexus
    Nexus 10
    Nexus 4
    Nexus 5
    Nexus 5X
    Nexus 6
    Nexus 6P
    Nexus 7 2013
    Nexus 7
    Nexus 9
    Nexus One
    Nexus S
    pixel
    pixel_c
    pixel_xl
    2.7in QVGA
    2.7in QVGA slider
    3.2in HVGA slider (ADP1)
    3.2in QVGA (ADP2)
    3.3in WQVGA
    3.4in WQVGA
    3.7 FWVGA slider
    3.7in WVGA (Nexus One)
    4in WVGA (Nexus S)
    4.65in 720p (Galaxy Nexus)
    4.7in WXGA
    5.1in WVGA
    5.4in FWVGA
    7in WSVGA (Tablet)
    10.1in WXGA (Tablet)
    

    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:

    system-images;android-27;google_apis;x86
    system-images;android-27;google_apis_playstore;x86
    

    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.

    WDYT @mit-mit @devoncarew?

  7. mit-mit commented on Jun 6, 2018

    @mit-mit
    MemberAuthor

    I'd say we just pick a Pixel image. We want the one that has playstore APIs for best compatibility.

  8. DanTup commented on Jun 6, 2018

    @DanTup
    Contributor

    Got a basic version of this working, looking for feedback: #18235

  9. 4 remaining items

  10. DanTup commented on Jul 30, 2018

    @DanTup
    Contributor

    @mit-mit @devoncarew Should we consider this done, or do we want to update IntelliJ with any of this?

  11. devoncarew commented on Aug 20, 2018

    @devoncarew
    Contributor

    I think we can close this issue, and open a more IntelliJ specific issue.

  12. JosephDunivan commented on Dec 5, 2018

    @JosephDunivan

    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.

  13. DanTup commented on Dec 5, 2018

    @DanTup
    Contributor

    @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.

  14. JosephDunivan commented on Dec 5, 2018

    @JosephDunivan

    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.

  15. DanTup commented on Dec 5, 2018

    @DanTup
    Contributor

    @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?

  16. JosephDunivan commented on Dec 5, 2018

    @JosephDunivan

    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
    
  17. DanTup commented on Dec 5, 2018

    @DanTup
    Contributor

    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?

  18. JosephDunivan commented on Dec 5, 2018

    @JosephDunivan

    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):

    export ANDROID_HOME=/Users//Library/Android/sdk
    export ANDROID_SDK_ROOT=$ANDROID_HOME

    But still I had to run flutter config.

  19. DanTup commented on Dec 5, 2018

    @DanTup
    Contributor

    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?)

  20. JosephDunivan commented on Dec 5, 2018

    @JosephDunivan

    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.

  21. DanTup commented on Dec 5, 2018

    @DanTup
    Contributor

    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.

  22. github-actions commented on Aug 16, 2021

    @github-actions

    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.

  23. locked as resolved and limited conversation to collaborators on Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: first hourThe first hour of using Flutterplatform-androidAndroid applications specifically

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions