[英]Cannot run android emulator using Command line tools on Linux (PANIC: Broken AVD system path.)
I'm trying to set up Jenkins slave machine for UI tests of an android project.我正在尝试为 android 项目的 UI 测试设置 Jenkins 从机。 I've run out of ideas how to proceed when I encountered this issue trying to run android emulator:
当我在尝试运行 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]!
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. /var/lib/android/android/system-images/(...)
中重复的android
文件夹看起来不正确,但我不知道这是从哪里来的。 I think it should be /var/lib/android/system-images/(...)
.我认为它应该是
/var/lib/android/system-images/(...)
。
Details:细节:
Earlier I've done complete setup of android sdk this way早些时候我用这种方式完成了 android sdk 的完整设置
/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>"
我已经使用
sdkmanager --sdk_root=${ANDROID_HOME} "<package>"
安装了包
current sdkmanager listing:当前 sdkmanager 列表:
[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:我这样创建了 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
My.bashrc contains this: My.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
these SDK paths exists:这些 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
The environment is CentOS 7 linux distribution running on a vmware环境是 CentOS 7 linux 分布运行在一个vmware上
I was able to run the emulator with fixing the image.sysdir.1
entry in /.android/avd/<avd_name>.avd/config.ini
file.我能够通过修复
/.android/avd/<avd_name>.avd/config.ini
文件中的image.sysdir.1
条目来运行模拟器。
I found this tip in in this question: PANIC: Broken AVD system path.我在这个问题中找到了这个提示: PANIC: Broken AVD system path。 Check your ANDROID_SDK_ROOT value
检查您的 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).
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.虽然您可以按照建议通过编辑 avd 中的 config.ini 来修复该症状,但我发现,至少在我的情况下,最初的原因是 android sdk 的目录结构。 It seems that the sdk wants a VERY precise structure in recent versions, specifically:
似乎 sdk 在最近的版本中想要一个非常精确的结构,特别是:
<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.我不确定名称是否重要,但似乎 <sdk_root> 和命令行工具“bin”目录之间有两个级别。 I suspect avdmanager is going up a fixed number of directories from the "bin" to look for SDK directories.
我怀疑 avdmanager 正在从“bin”中查找固定数量的目录以查找 SDK 目录。 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.
因此,在您的情况下,将您的工具目录放在另一个子目录下,更新您的 PATH 变量以指向新位置,然后重试。
Both above answers are look like workarounds.以上两个答案看起来都像是解决方法。 Actually you have to install
cmdline-tools;latest
package and execute the avdmanager
from there.实际上,您必须安装
cmdline-tools;latest
package 并从那里执行avdmanager
。
# 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现在应该可以从这里运行
advmanager
而不会出现任何错误
# 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.