无法在Linux上使用命令行工具运行android模拟器(PANIC:断开的AVD系统路径)



我正在尝试为android项目的UI测试设置Jenkins从机。当我在尝试运行android模拟器时遇到这个问题时,我已经没有办法继续了:

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

我错过了什么?

/var/lib/android/android/system-images/(...)中重复的android文件夹看起来不太对劲,但我不知道这是从哪里来的。我认为应该是/var/lib/android/system-images/(...)

详细信息:

早些时候,我已经完成了安卓sdk的完整设置这种方式

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

我已经使用sdkmanager --sdk_root=${ANDROID_HOME} "<package>"安装了软件包

当前sdkmager列表:

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

我是这样创建avd的:

[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

我的.bashrc包含以下内容:

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

存在以下SDK路径:

/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

环境是在vmware 上运行的CentOS 7 linux发行版

对于其他对此感兴趣的人:

虽然你可以按照建议通过编辑avd中的config.ini来修复症状,但我发现,至少在我的情况下,最初的原因是android sdk的目录结构。在最近的版本中,sdk似乎想要一个非常精确的结构,特别是:

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

我不确定这些名字是否重要,但似乎在<sdk_root>以及您的命令行工具";bin";目录是。我怀疑avdmanager正在从";bin";以查找SDK目录。因此,在您的情况下,将工具目录放在另一个子目录下,更新PATH变量以指向新位置,然后重试。

我能够通过修复/.android/avd/<avd_name>.avd/config.ini文件中的image.sysdir.1条目来运行模拟器。

我在这个问题中发现了这个提示:PANIC:断开的AVD系统路径。检查您的ANDROID_SDK_ROOT值

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).

实际上,您必须安装cmdline-tools;latest包并从那里执行avdmanager

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

advmanager应该从这里运行,现在没有任何错误

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

这里的文件夹你必须看到之后

/opt/android-sdk/cmdline-tools/
├── bin
├── latest
│   ├── bin
│   └── lib
└── lib

相关内容

  • 没有找到相关文章

最新更新