0

I am trying to install and run an Android Virtual Device from the command line on Windows (without Android Studio). I have set up an Android SDK in C:\Android, and successfully created an AVD with the command:

avdmanager create avd -n test -k "system-images;android-26;google_apis_playstore;x86" --abi google_apis_playstore/x86

I have environment variable ANDROID_SDK_ROOT set to C:\Android.

When I try to start the emulator from the command line with:

emulator @test

I get errors:

emulator: ERROR: can't find SDK installation directory
emulator: could not find virtual device named 'test'

I have also tried setting environment variables ANDROID_AVD_HOME and ANDROID_EMULATOR_HOME, and also tried running the AVD specifying sysdir and datadir with the command:

emulator @test -sysdir C:\Android\system-images\android-26\google_apis_playstore\x86 -datadir C:\Android\avd

but I get the same errors.

When I run command avdmanager.bat list avd, I get:

    Name: test
    Path: C:\Android\avd\test.avd
  Target: Google Play (Google Inc.)
          Based on: Android API 26 Tag/ABI: google_apis_playstore/x86

Why on earth can't I run the AVD?

AndrWeisR
  • 1,110
  • 11
  • 21

2 Answers2

6

I found the problem. Because I was trying to do a minimal Android SDK install via the command line, I did not yet have a platform-tools folder. Not being able to find the platform-tools folder was causing the emulator to display the unhelpful error "can't find SDK installation directory", which really meant "can't find the platform-tools directory".

Once I installed the platform-tools folder with sdkmanager --no_https "platform-tools", the emulator worked. I need --no_https because I'm in a crippled corporate environment.

For future reference, I installed the emulator dependencies (after unzipping sdk-tools-windows-3859397.zip from here) with:

sdkmanager --no_https "system-images;android-26;google_apis_playstore;x86" "platforms;android-26" "platform-tools" "emulator"
AndrWeisR
  • 1,110
  • 11
  • 21
0

With the package "platform-tools", it may also required to install "platforms;android-26" for your Android 26. Using sdkmanager.bat platforms;android-30 --sdk_root=C:\your_avd_sdk_root to install it.

If still not working, try to run command below:

set PATH=%PATH%;%ANDROID_SDK_ROOT%\emulator
set PATH=%PATH%;%ANDROID_SDK_ROOT%\emulator\bin64
set PATH=%PATH%;%ANDROID_SDK_ROOT%\platform-tools
set PATH=%PATH%;%ANDROID_SDK_ROOT%\cmdline-tools\latest\bin
vrqq
  • 448
  • 3
  • 8