3

Repro:

  1. Headless Ubuntu 18.04 LTS VM (kvm note enabled)
  2. sudo apt-get update
  3. sudo apt-get install -y wget openjdk-8-jre-headless libc6-i386 lib32stdc++6 python3-pip nginx unzip
  4. sudo wget https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip
  5. sudo unzip commandlinetools-linux-6200805_latest.zip -d /opt
  6. sudo /opt/tools/bin/sdkmanager --install --sdk_root=/opt "system-images;android-19;default;armeabi-v7a" "platform-tools" "platforms;android-19"
  7. /opt/tools/bin/avdmanager create avd -n arm -k "system-images;android-19;default;armeabi-v7a" -f

On step 7 in hangs with Loading local repository...

Notes:

  • Running the avdmanager as sudo doesn't help, and the image need's to be created by a user anyway.
  • Tried sudo setfacl -m u:username:rwx /opt/tools/bin/avdmanager didn't help
  • setting ANDROID_HOME=/opt and PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools doesn't help
  • newer version of command line tools don't help ether (step 4).

What is the problem? How can I investigate? Have I missed something?

Anton Toshik
  • 2,621
  • 2
  • 19
  • 42

2 Answers2

5

I encountered the same problem. I believe there may be something wrong with the avdmanager or sdkmanager because it always identifies a wrong sdk_root path. For example, if I create a folder under my root on the server (e.g., /root/SDK) as the sdk root, the avdmanager does not search for folders like emulator, platform-tools, etc, under root/SDK. It turns out it always searches in an upper level folder (i.e., /root). If there are many things in the /root, the search process will take a lot of time, that's the reason why it hangs on "loading local repository". If you wait enough time, you will eventually see the result. So to word around this, my solution is to put sdk root in one deeper folder level (e.g., /root/SDK/android_sdk_linux). The avdmanager still starts searching in the upper level folder (i.e., /root/SDK), but it's very quick because there is nothing in /root/SDK. There can be some warnings output by avdmanager but you can ignore them because in my experience there is no side effects.

Richard Hu
  • 811
  • 5
  • 18
5

It happened because since version (6200805) Command Line Tools should be placed inside cmdline-tools directory. It should be created manually in ANDROID_HOME.

Please see this answer. With the mentioned configuration everything works fine.

Prateek Gupta
  • 2,422
  • 2
  • 16
  • 30
Wewe
  • 156
  • 4