Android emulator errors with “emulator: ERROR: can't find SDK installation directory”

杀马特。学长 韩版系。学妹 提交于 2020-08-10 21:13:48

问题


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?


回答1:


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"


来源:https://stackoverflow.com/questions/49868458/android-emulator-errors-with-emulator-error-cant-find-sdk-installation-direc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!