You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CentOS7下Jenkins-AndroidEmulator插件创建AVD失败求助

Troubleshooting Jenkins-AndroidEmulator + Maven Headless Emulator Issue on CentOS 7

Hey there, let's break down why your Appium script works smoothly on Windows with Genymotion but hits snags on CentOS 7 using Jenkins' Android Emulator plugin. I've dealt with similar headaches before, so here are the key areas to check and fix:

1. Headless Mode & Graphics Context Conflicts

Even though your CentOS server has a GUI, Jenkins might not be running with the right graphical context to launch the emulator properly:

  • First, check if the DISPLAY environment variable is set for the Jenkins user. Add this echo command to your build steps to verify:
    echo $DISPLAY
    
    If it returns empty, manually set it before starting the emulator (adjust :0 to match your server's display number if needed):
    export DISPLAY=:0
    
  • Double-check that the Jenkins Android Emulator plugin is passing the correct headless flags. Look through your build logs for the emulator startup command—it should include either -no-window or -headless (depending on your emulator version). If not, tweak the plugin's configuration to add these parameters.

2. AVD & Virtualization Compatibility

Your AVD might not be optimized for CentOS's server environment:

  • Verify KVM support: Android emulators rely on KVM for performance, and it's often disabled by default on servers. Run this command to check if your CPU supports virtualization:
    egrep -c '(vmx|svm)' /proc/cpuinfo
    
    If the output is 0, enable virtualization in your server's BIOS, then load the KVM module:
    # For Intel CPUs
    modprobe kvm-intel
    # For AMD CPUs
    modprobe kvm-amd
    
    Add these modules to /etc/modules-load.d/kvm.conf to make the change persistent on reboot.
  • Check the AVD system image: Make sure you downloaded the Linux version of the android-26 system image (not the Windows one). List your AVDs to confirm:
    avdmanager list avd
    
    Ensure the image path points to a Linux-compatible file under your Android SDK's system-images directory.

3. Jenkins Plugin & Maven Integration

The plugin might not be properly prepping the emulator before your tests run:

  • Double-check plugin settings: Confirm the plugin is using the correct Android SDK path, and the AVD name matches exactly what you created—typos here are a super common culprit.
  • Wait for the emulator to fully boot: Emulators take time to finish initializing; don't jump straight to running tests. Add these steps to your build to wait for the device to be ready:
    adb wait-for-device
    # Wait for the system to complete bootup
    until adb shell getprop sys.boot_completed | grep -m 1 1; do sleep 1; done
    
  • Update Appium capabilities: Tweak your Maven-configured Appium caps to fit the headless emulator. For example:
    capabilities.setCapability("avd", "YourExactAVDName");
    capabilities.setCapability("avdLaunchTimeout", 120000); // Extend timeout if needed
    capabilities.setCapability("noReset", true);
    

4. Permissions & Missing Dependencies

CentOS often lacks some libraries needed for the emulator, and permission issues can block AVD access:

  • Fix AVD directory permissions: Ensure the Jenkins user has read/write access to ~/.android/avd/ and your Android SDK directory. If Jenkins runs as root (not ideal), adjust ownership with:
    chown -R jenkins:jenkins ~/.android/
    
  • Install missing libraries: Run this command to check for missing dependencies in the emulator binary:
    ldd $ANDROID_HOME/emulator/emulator
    
    Install any missing packages with yum—common ones include:
    yum install mesa-libGL-devel libstdc++.i686
    

内容的提问来源于stack exchange,提问作者Suresh Sharma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 08:25:42