Cannot launch Android emulator created by AVD Manager on macOS stack

I’m trying to run Android emulator on macOS Stack (Visual Studio for Mac, stable).

Unfortunately step AVD Manager fails no matter what kind of emulator is chosen. It fails both for x86 emulators as well as for ARM.

In case of x86 emualtors it fails due to HAXM requirements, but in case of ARM it’s unable to download dependencies.

Sample build that failed: https://app.bitrise.io/build/5784a7f0b64ec65c#?tab=log

Log:

INFO[18:32:13]  * [OK] Step dependency (go) installed, available. 
Configs:
- Version: 26
- Resolution: 240x426
- Density: 120
- Orientation: portrait
- Tag: google_apis
- ABI: armeabi-v7a
- Profile: Nexus 6P
- ID: emulator
- CustomCommandFlags: -no-window -no-audio -debug-init
- Overwrite: true
- CustomConfig:
disk.dataPartition.size=1024M
hw.camera.back=emulated
hw.camera.front=emulated
hw.keyboard=yes
hw.gpu.enabled=true
hw.gpu.mode=swiftshader
hw.ramSize=1536
runtime.network.latency=none
runtime.network.speed=full
showDeviceFrame=no
skin.dynamic=yes
skin.path=_no_skin
skin.path.backup=_no_skin
vm.heapSize=384
Ensure sdk packages: [tools platform-tools system-images;android-26;google_apis;armeabi-v7a]
Failed to update emulator sdk package, error: exit status 1, output: Loading package information...                                                  
Loading local repository...                                                     
[                                       ] 3% Loading local repository...        
[                                       ] 3% Fetch remote repository...         
[                                       ] 3% Fetch remote repository...         
[=                                      ] 3% Fetch remote repository...         
[=                                      ] 3% Fetch remote repository...         
[=                                      ] 3% Fetch remote repository...         
[=                                      ] 3% Fetch remote repository...         
[=                                      ] 3% Fetch remote repository...         
[=                                      ] 3% Fetch remote repository...         
[=                                      ] 3% Fetch remote repository...         
[=                                      ] 3% Fetch remote repository...         
[=                                      ] 3% Fetch remote repository...         
[=                                      ] 3% Fetch remote repository...         
[=                                      ] 3% Fetch remote repository...         
[=                                      ] 3% Fetch remote repository...         
[=                                      ] 4% Fetch remote repository...         
[=                                      ] 4% Fetch remote repository...         
[=                                      ] 4% Fetch remote repository...         
[=                                      ] 4% Fetch remote repository...         
[=                                      ] 4% Fetch remote repository...         
[=                                      ] 4% Fetch remote repository...         
[=                                      ] 4% Fetch remote repository...         
[=                                      ] 4% Fetch remote repository...         
[=                                      ] 4% Fetch remote repository...         
                                                                                
Warning: File /Users/vagrant/.android/repositories.cfg could not be loaded.
[=                                      ] 4% Fetch remote repository...         
[==                                     ] 5% Fetch remote repository...         
[==                                     ] 6% Fetch remote repository...         
[==                                     ] 6% Computing updates...               
[===                                    ] 8% Computing updates...               
[===                                    ] 8% Computing updates...               
[===                                    ] 10% Computing updates...              
                                                                                
Warning: Failed to find package system-images;android-26;google_apis;armeabi-v7a
[===                                    ] 10% Computing updates...

Sorry about the issue @dominik.roszkowski!

As I believe you might have seen in the original emulator thread, we’re not seeing the AVD Manager working reliably on any other environment than the LTS stack at the monent unfortunately :frowning: What is your use case for the Android Emulator on a macOS?

I’d like to perform Flutter UI tests on both iPhone simulator and Android emulator. Unfortunately when using Android stack I need to install Flutter and some other tools required for UI testing.

Such package simply does not exist. The newest image for armeabi-v7a uses API level 25. You are requesting 26.

Thanks!

So I tried to fix it but unfortunately Android emulator does not start.
Please take a look at my build: https://app.bitrise.io/build/af76b17344014654#?tab=log

   +1 ms] executing: /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/emulator/emulator -avd Android -no-audio -no-window -no-snapshot -gpu swiftshader
[   +1 ms] executing: [./] /tmp/screenshots/resources/script/android-wait-for-emulator
[ +228 ms] Waiting for emulator to start: 599 of 600 : status: error: no emulators found
[+1133 ms] Waiting for emulator to start: 598 of 600 : status: error: no emulators found
[+1048 ms] Waiting for emulator to start: 597 of 600 : status: error: no emulators found

I created the emulator via:

avdmanager create avd --name "Android" -k "system-images;android-25;google_apis;armeabi-v7a" -f -d 11

Any ideas when this will get fixed - I’m trying to use it for the same reason of running Flutter UI tests (integration tests via Flutter driver) and getting the same failing AVD Manager issue. Thanks

I got an answer directly that Bitrise team is investigating the issue. I hope this will be easy to fix :crossed_fingers:

1 Like

Hi @koral and @bitce is there any update on running Android emulators on macOS stacks?

I’m not a Bitrise employee :wink: so I don’t have any more information.

Hey everyone!

Sorry for the silence on this. I am updating this thread to include a script we’ve recently found to be successfully launching emulators:

#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x

# write your script here
sudo $ANDROID_HOME/tools/bin/sdkmanager --update
$ANDROID_HOME/tools/bin/sdkmanager --install "emulator"
$ANDROID_HOME/tools/bin/sdkmanager --install "system-images;android-29;google_apis;x86"
echo "no" | $ANDROID_HOME/tools/bin/avdmanager --verbose create avd --force --name "pixel" --device "pixel" --package "system-images;android-29;google_apis;x86" --tag "google_apis" --abi "x86"
$ANDROID_HOME/emulator/emulator-headless @pixel -no-boot-anim -netdelay none -no-snapshot -wipe-data -verbose -show-kernel -no-audio -gpu swiftshader_indirect -no-snapshot &> /tmp/log.txt &
sleep 160

Note that you can disregard the sleep 160 in case this time passes between launching and using the emulator.

Anyone still struggling with this, please give it a try and let us know how it goes.

1 Like

I think you’ll need an echo y | in front of that first command to accept the License Agreement. I was able to install an emulator with just this command alone:

echo no | $ANDROID_HOME/tools/bin/avdmanager create avd --force --name testAVD --abi google_apis/x86 --package 'system-images;android-26;google_apis;x86'

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.