title: Cannot run android emulator using Command line tools on Linux (PANIC: Broken AVD system path.)
body: <p>I'm trying to set up Jenkins slave machine for UI tests of an android project. I've run out of ideas how to proceed when I encountered this issue trying to run android emulator:</p>
  
  <pre><code>[myuser@jenkins-slave-002 emulator]$ export ANDROID_SDK_ROOT="/var/lib/android"
  [myuser@jenkins-slave-002 emulator]$ ./emulator -avd pixel-2-api28 -no-window -verbose -show-kernel
  emulator: Android emulator version 30.0.5.0 (build_id 6306047) (CL:N/A)
  emulator: Found AVD name 'pixel-2-api28'
  emulator: Found AVD target architecture: x86
  emulator: argv[0]: './emulator'; program directory: '/var/lib/android/emulator'
  emulator:  Not a directory: /var/lib/android/android/system-images/android-28/google_apis/x86/
  
  PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [/var/lib/android]!
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p>Duplicated <code>android</code> folder in <code>/var/lib/android/android/system-images/(...)</code> doesn't look right, but I have no idea where this comes from. I think it should be <code>/var/lib/android/system-images/(...)</code>.</p>
  
  <p><strong>Details:</strong></p>
  
  <p>Earlier I've done complete setup of android sdk this way</p>
  
  <pre><code>/lib/var/android/ unzip commandlinetools-linux-6200805_latest.zip (taken from https://developer.android.com/studio#command-tools)
  </code></pre>
  
  <p>I've installed packages using <code>sdkmanager --sdk_root=${ANDROID_HOME} "&lt;package&gt;"</code></p>
  
  <p>current sdkmanager listing:</p>
  
  <pre><code>[myuser@jenkins-slave-002 bin]$ sdkmanager --sdk_root=${ANDROID_HOME} --list
  
  Installed packages:=====================] 100% Computing updates...             
    Path                                     | Version | Description                             | Location                                 
    -------                                  | ------- | -------                                 | -------                                  
    emulator                                 | 30.0.5  | Android Emulator                        | emulator/                                
    patcher;v4                               | 1       | SDK Patch Applier v4                    | patcher/v4/                              
    platform-tools                           | 29.0.6  | Android SDK Platform-Tools              | platform-tools/                          
    platforms;android-28                     | 6       | Android SDK Platform 28                 | platforms/android-28/                    
    system-images;android-28;google_apis;x86 | 10      | Google APIs Intel x86 Atom System Image | system-images/android-28/google_apis/x86/
    tools                                    | 1.0.0   | Android SDK Tools 1                     | tools/                                   
  </code></pre>
  
  <p>I created avd this way:</p>
  
  <pre><code>[myuser@jenkins-slave-002 bin]$ avdmanager create avd -n pixel-2-api28 --device "pixel_2" -k "system-images;android-28;google_apis;x86"
  
  Warning: Observed package id 'emulator' in inconsistent location '/var/lib/android/emulator' (Expected '/var/lib/emulator')
  Warning: Observed package id 'patcher;v4' in inconsistent location '/var/lib/android/patcher/v4' (Expected '/var/lib/patcher/v4')
  Warning: Observed package id 'platform-tools' in inconsistent location '/var/lib/android/platform-tools' (Expected '/var/lib/platform-tools')
  Warning: Observed package id 'platforms;android-28' in inconsistent location '/var/lib/android/platforms/android-28' (Expected '/var/lib/platforms/android-28')
  Warning: Observed package id 'system-images;android-28;google_apis;x86' in inconsistent location '/var/lib/android/system-images/android-28/google_apis/x86' (Expected '/var/lib/system-images/android-28/google_apis/x86')
  Warning: Observed package id 'tools' in inconsistent location '/var/lib/android/tools' (Expected '/var/lib/tools')
  Auto-selecting single ABI x86===========] 100% Fetch remote repository...       
  Parsing /var/lib/android/emulator/package.xmlParsing /var/lib/android/patcher/v4/package.xmlParsing /var/lib/android/platform-tools/package.xmlParsing /var/lib/android/platforms/android-28/package.xmlParsing /var/lib/android/system-images/android-28/google_apis/x86/package.xmlParsing /var/lib/android/tools/package.xml
  </code></pre>
  
  <p>My .bashrc contains this:</p>
  
  <pre><code>export PATH="/var/lib/android/tools:$PATH"
  export PATH="/var/lib/android/tools/bin:$PATH"
  export ANDROID_SDK_HOME=/var/lib/android
  export ANDROID_HOME=/var/lib/android
  </code></pre>
  
  <p>these SDK paths exists:</p>
  
  <pre><code>/var/lib/android/tools/bin
  /var/lib/android/tools/lib
  /var/lib/android/tools
  /var/lib/android/.android/cache
  /var/lib/android/.android/avd/pixel-2-api28.avd
  /var/lib/android/.android/avd
  /var/lib/android/licenses
  /var/lib/android/patcher/v4
  /var/lib/android/patcher
  /var/lib/android/.temp
  /var/lib/android/emulator/
  /var/lib/android/platform-tools/
  /var/lib/android/system-images/android-28
  /var/lib/android/platforms/android-28
  </code></pre>
  
  <p>The environment is CentOS 7 linux distribution running on a vmware</p>