Android эмулятор не запускается с конвейером Jenkins и android sdk - PullRequest
0 голосов
/ 22 января 2020

у нас проблема в том, что на Linux машине (Debian) эмулятор Android не запускается через Jenkins и локально.

Наша процедура подготовки:


#!/bin/bash
# Android Studio
apt-get update
apt-get -y install unzip
apt-get -y install qt5-default
apt-get install xvfb

if [[ ! -f "sdk-tools-linux-4333796.zip" ]]; then
    wget -q https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
fi
unzip -o sdk-tools-linux-4333796.zip -d /usr/share/

# Install platform tools
/usr/share/tools/bin/sdkmanager --update
echo yes | /usr/share/tools/bin/sdkmanager platform-tools
echo yes | /usr/share/tools/bin/sdkmanager emulator

ln -s /usr/share/platform-tools/adb /usr/local/bin/adb
ln -s /usr/share/emulator/emulator-headless /usr/local/bin/emulator-headless
ln -s /usr/share/emulator/emulator /usr/local/bin/emulator
ln -s /usr/share/tools/android /usr/local/bin/android
mkdir -p /usr/share/platforms

# Create  emulator and accept licenses
echo yes | /usr/share/tools/bin/sdkmanager "system-images;android-28;google_apis;x86"
echo no | /usr/share/tools/bin/avdmanager create avd -n emulator-5554 -k "system-images;android-28;google_apis;x86" --force --path "$HOME/.android/avd"
apt-get -y install libgl1

if [[ ! -f "selenium-server-standalone-3.141.59.jar" ]]; then
    wget -q https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar
fi

# Appium
set -x

npm install -g appium --unsafe-perm=true --allow-root
npm install -g wd --unsafe-perm=true --allow-root

# Create node config for device
mkdir -p nodeconfig
cat > nodeconfig/emulator-5554.json << EOF
{
  "capabilities": [
    {
      "deviceName": "emulator-5554",
      "browserName": "chrome",
      "version": "9",
      "maxInstances": 2,
      "platform": "Android",
      "platformName": "ANDROID"
    }
  ],
  "configuration": {
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "maxSession": 5,
    "port": $APPIUM_PORT,
    "url": "http://127.0.0.1:$APPIUM_PORT",
    "host": "127.0.0.1",
    "register": true,
    "registerCycle": 5000,
    "hub": "http://$HUB_HOST:$HUB_PORT",
    "hubPort": "$HUB_PORT",
    "hubHost": "$HUB_HOST",
    "nodeStatusCheckTimeout": 5000,
    "nodePolling": 5000,
    "role": "node",
    "unregisterIfStillDownAfter": 60000,
    "downPollingLimit": 2,
    "debug": false,
    "servlets": [],
    "withoutServlets": []
  }
}
EOF

# Selenium
screen -dmS selenium -L -Logfile selenium.log java -jar selenium-server-standalone-3.141.59.jar -port $HUB_PORT -role hub

# Emulator
screen -dmS emulator -L -Logfile emulator.log xvfb-run emulator -avd emulator-5554 "system-images;android-28;google_apis;x86"

Сообщения об ошибках

Я вижу это сообщение об ошибке, когда я добавляю «-verbose»

emulator: Android emulator version 29.3.4.0 (build_id 6110076) (CL:N/A)
emulator: Found AVD name 'emulator-5554'
emulator: Found AVD target architecture: x86_64
emulator: argv[0]: 'emulator'; program directory: '/usr/share/emulator'
emulator:  Found directory: /usr/share/system-images/android-28/google_apis/x86_64/

emulator: emuDirName: '/usr/share/emulator'
emulator: try dir /usr/share/emulator
emulator: Trying emulator path '/usr/share/emulator/qemu/linux-x86_64/qemu-system-x86_64'
emulator: Found target-specific 64-bit emulator binary: /usr/share/emulator/qemu/linux-x86_64/qemu-system-x86_64
emulator: Adding library search path: '/usr/share/emulator/lib64'
emulator: Adding library search path: '/usr/share/emulator/lib64/gles_angle'
emulator: Adding library search path: '/usr/share/emulator/lib64/gles_angle9'
emulator: Adding library search path: '/usr/share/emulator/lib64/gles_angle11'
emulator: Adding library search path: '/usr/share/emulator/lib64/gles_swiftshader'
emulator: Adding library search path: '/usr/share/emulator/lib64/libstdc++'
emulator: Adding library search path for Qt: '/usr/share/emulator/lib64/qt/lib'
emulator: Silencing all qWarning(); use qCWarning(...) instead: QT_LOGGING_RULES=default.warning=false
emulator: Setting Qt plugin search path: QT_QPA_PLATFORM_PLUGIN_PATH=/usr/share/emulator/lib64/qt/plugins
emulator: Setting Qt to use software OpenGL: QT_OPENGL=software
emulator: Setting QML to use software QtQuick2D: QMLSCENE_DEVICE=softwarecontext
emulator: Overriding pre-existing bad Qt high dpi settings...
emulator: Setting LD_PRELOAD to /usr/share/emulator/lib64/qt/lib/libfreetype.so.6
emulator: Running :/usr/share/emulator/qemu/linux-x86_64/qemu-system-x86_64
emulator: qemu backend: argv[00] = "/usr/share/emulator/qemu/linux-x86_64/qemu-system-x86_64"
emulator: qemu backend: argv[01] = "-avd"
emulator: qemu backend: argv[02] = "emulator-5554"
emulator: qemu backend: argv[03] = "-gpu"
emulator: qemu backend: argv[04] = "swiftshader_indirect"
emulator: qemu backend: argv[05] = "-verbose"
emulator: Concatenated backend parameters:
 /usr/share/emulator/qemu/linux-x86_64/qemu-system-x86_64 -avd emulator-5554 -gpu swiftshader_indirect -verbose
emulator: autoconfig: -skin HVGA
emulator: autoconfig: -skindir (null)
emulator: autoconfig: -kernel /usr/share/system-images/android-28/google_apis/x86_64//kernel-ranchu
emulator: Target arch = 'x86_64'
emulator: Auto-detect: Kernel image requires new device naming scheme.
emulator: Auto-detect: Kernel does not support YAFFS2 partitions.
emulator: autoconfig: -ramdisk /usr/share/system-images/android-28/google_apis/x86_64//ramdisk.img
emulator: Using initial system image: /usr/share/system-images/android-28/google_apis/x86_64//system.img
emulator: Using initial vendor image: /usr/share/system-images/android-28/google_apis/x86_64//vendor.img
emulator: autoconfig: -data /root/.android/avd/userdata-qemu.img
emulator: autoconfig: -initdata /root/.android/avd/userdata.img
emulator: autoconfig: -cache /root/.android/avd/cache.img
emulator: Increasing RAM size to 1536MB
emulator: VM heap size 0MB is below hardware specified minimum of 384MB,setting it to that value
emulator: System image is read only
emulator: skin name 'HVGA' aliased to '320x480'
emulator: found magic skin width=320 height=480 bpp=16

emulator: VERBOSE: System.cpp:2342: statvfs('/root/.android/avd/snapshots/default_boot/ram.img') failed: No such file or directory

emulator: registered 'boot-properties' qemud service
emulator: Adding boot property: 'qemu.cmdline' = 'androidboot.logcat=v:* androidboot.consolepipe=qemu_pipe,pipe:logcat'
emulator: Adding boot property: 'qemu.logcat' = 'start'
emulator: CPU Acceleration: working
emulator: CPU Acceleration status: KVM (version 12) is installed and usable.
Segmentation fault

Без «-verbose» я просто вижу сообщение об ошибке:

Segmentation fault

Я также пытался запустить эмулятор без «xvfb-run», но затем я вижу это сообщение об ошибке:

emulator: INFO: QtLogger.cpp:68: Warning: QXcbConnection: Could not connect to display  ((null):0, (null))


emulator: INFO: QtLogger.cpp:68: Critical: Could not connect to any X display. ((null):0, (null))
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...