skip to Main Content

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:

[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]!

What am I missing?

Duplicated android folder in /var/lib/android/android/system-images/(...) doesn’t look right, but I have no idea where this comes from. I think it should be /var/lib/android/system-images/(...).

Details:

Earlier I’ve done complete setup of android sdk this way

/lib/var/android/ unzip commandlinetools-linux-6200805_latest.zip (taken from https://developer.android.com/studio#command-tools)

I’ve installed packages using sdkmanager --sdk_root=${ANDROID_HOME} "<package>"

current sdkmanager listing:

[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/                                   

I created avd this way:

[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

My .bashrc contains this:

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

these SDK paths exists:

/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

The environment is CentOS 7 linux distribution running on a vmware

3

Answers


  1. Chosen as BEST ANSWER

    I was able to run the emulator with fixing the image.sysdir.1 entry in /.android/avd/<avd_name>.avd/config.ini file.

    I found this tip in in this question: PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value

    Go to <user_home>/.android/avd/<avd_name> and open config.ini. Find the image.sysdir.1 property. It points at the directory, inside the SDK directory, that contains the actual system image. Make sure that this directory exists and contains files like build.prop, system.img, etc. If it doesn't, then you have to open the SDK Manager and download system images your AVD requires (see below).
    

  2. For others interested in this:

    Whilst you can fix the symptom by editing the config.ini in the avd as suggested, I found that, in my case at least, the initial cause was the directory structure of the android sdk.
    It seems that the sdk wants a VERY precise structure in recent versions, specifically:

    <sdk_root> - cmdline-tools - tools - bin
                                       - lib
    

    I’m not sure if the names are important, but it seems that having TWO levels between <sdk_root> and your command line tools "bin" directory is. I suspect avdmanager is going up a fixed number of directories from the "bin" to look for SDK directories.
    So in your case, put your tools directory under an additional subdirectory, update your PATH variable to point to the new location and try again.

    Login or Signup to reply.
  3. Actually you have to install cmdline-tools;latest package and execute the avdmanager from there.

    # sdkmanager --sdk_root=/opt/android-sdk --install "cmdline-tools;latest"
    # export PATH=$PATH:/opt/android-sdk/cmdline-tools/latest/bin
    

    The advmanager should be run from here without any errors now

    # which avdmanager
    /opt/android-sdk/cmdline-tools/latest/bin/avdmanager
    

    Here the folders you have to see afterwards

    /opt/android-sdk/cmdline-tools/
    ├── bin
    ├── latest
    │   ├── bin
    │   └── lib
    └── lib
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search