Jenkins cannot run an android emulator.
[android] Using Android SDK: /opt/android-sdk-linux
[android] Creating Android AVD: /var/lib/jenkins/.android/avd/hudson_en-US_240_WVGA_android-23_google_apis-x86_64.avd
[android] /opt/android-sdk-linux/tools/android create avd -f -a -s WVGA800 -n hudson_en-US_240_WVGA_android-23_google_apis-x86_64 -t android-23 --abi google_apis/x86_64
$ /opt/android-sdk-linux/platform-tools/adb start-server
* daemon not running. starting it now at tcp:5837 *
* daemon started successfully *
$ /opt/android-sdk-linux/platform-tools/adb start-server
[android] Starting Android emulator
$ /opt/android-sdk-linux/tools/emulator -engine classic -ports 5682,5683 -report-console tcp:5827,max=60 -prop persist.sys.language=en -prop persist.sys.country=US -avd hudson_en-US_240_WVGA_android-23_google_apis-x86_64 -no-snapshot-load -no-snapshot-save -no-window
WARNING: Force to use classic engine to support snapshot.
[android] Emulator did not appear to start; giving up
[android] Stopping Android emulator
$ /opt/android-sdk-linux/platform-tools/adb kill-server
Finished: NOT_BUILT
Then, I try to run emulator the same as jenkins. The problem is android emulator is not starting to listen to the port. First, I created and started emulator successfully with the 'user' user as follow:
user@host:~$android create avd -f -a -s WVGA800 -n test -t android-23 --abi google_apis/x86_64
Android 6.0 is a basic Android platform.
Do you wish to create a custom hardware profile [no]no
Created AVD 'test' based on Android 6.0, Google apis Intel Atom (x86_64) processor,
with the following hardware config:
hw.lcd.density=240
hw.ramSize=512
vm.heapSize=48
user@host:~$ emulator -avd test -no-snapshot-load -no-snapshot-save -no-window
WARNING: Force to use classic engine to support snapshot.
emulator: WARNING: Classic qemu does not support SMP. The hw.cpu.ncore option from your config file is ignored.
Creating filesystem with parameters:
Size: 69206016
Block size: 4096
Blocks per group: 32768
Inodes per group: 4224
Inode size: 256
Journal blocks: 1024
Label:
Blocks: 16896
Block groups: 1
Reserved block group size: 7
Created filesystem with 11/4224 inodes and 1302/16896 blocks
emulator: Listening for console connections on port: 5554
emulator: Serial number of this emulator (for ADB): emulator-5554
[139763360147200]:WARNING:./android/base/files/IniFile.cpp:158:Failed to process .ini file /home/user/.android/emu-update-last-check.ini for reading.
emulator: WARNING: UpdateCheck: Failure: No error
none.xml:1: parser error : Extra content at the end of the document
amp;uid=&os=Linuxversion=25.2.5.0&coreVersion=qemu1%200.10.50">Found</a>
^
emulator: WARNING: UpdateCheck: failed to get the latest version, skipping check (current version '25.2.5-3567187')
So everything is okey with 'user' user, but for 'jenkins' user I have problem
jenkins@host:~$ android create avd -f -a -s WVGA800 -n test -t android-23 --abi google_apis/x86_64
Android 6.0 is a basic Android platform.
Do you wish to create a custom hardware profile [no]no
Created AVD 'test' based on Android 6.0, Google apis Intel Atom (x86_64) processor,
with the following hardware config:
hw.lcd.density=240
hw.ramSize=512
vm.heapSize=48
jenkins@host:~$ emulator -avd test -no-snapshot-load -no-snapshot-save -no-window
WARNING: Force to use classic engine to support snapshot.
emulator: WARNING: Classic qemu does not support SMP. The hw.cpu.ncore option from your config file is ignored.
Creating filesystem with parameters:
Size: 69206016
Block size: 4096
Blocks per group: 32768
Inodes per group: 4224
Inode size: 256
Journal blocks: 1024
Label:
Blocks: 16896
Block groups: 1
Reserved block group size: 7
Created filesystem with 11/4224 inodes and 1302/16896 blocks
and that is it! No matter how much I wait the line of "emulator: Listening for console connections on port: 5554" is not coming!
BTW, kvm is running okey for both users
$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
Also, "ANDROID_HOME" and "HOME" environment parameters are okey.
Any suggestion?
UPDATE
I noticed this problem is not happening when I'm using google_apis/armeabi-v7a
abi. So I believe this problem is related to kvm installation, but I have not idea how to fix it.
jenkins@hosst:~$ android create avd -f -a -s WVGA800 -n test -t android-23 --abi google_apis/armeabi-v7a
Android 6.0 is a basic Android platform.
Do you wish to create a custom hardware profile [no]no
Created AVD 'test' based on Android 6.0, Google apis ARM (armeabi-v7a) processor,
with the following hardware config:
hw.lcd.density=240
hw.ramSize=512
vm.heapSize=48
jenkins@host:~$ emulator -avd test -no-window
WARNING: Force to use classic engine to support snapshot.
emulator: WARNING: System image is writable
emulator: WARNING: Classic qemu does not support SMP. The hw.cpu.ncore option from your config file is ignored.
[140306725234432]:WARNING:./android/base/files/IniFile.cpp:158:Failed to process .ini file /var/lib/jenkins/.android/avd/test.avd/snapshots.img.default-boot.ini for reading.
Creating filesystem with parameters:
Size: 69206016
Block size: 4096
Blocks per group: 32768
Inodes per group: 4224
Inode size: 256
Journal blocks: 1024
Label:
Blocks: 16896
Block groups: 1
Reserved block group size: 7
Created filesystem with 11/4224 inodes and 1302/16896 blocks
emulator: Listening for console connections on port: 5554
emulator: Serial number of this emulator (for ADB): emulator-5554
[140306725234432]:WARNING:./android/base/files/IniFile.cpp:158:Failed to process .ini file /var/lib/jenkins/.android/emu-update-last-check.ini for reading.
emulator: WARNING: UpdateCheck: Failure: No error
none.xml:1: parser error : Extra content at the end of the document
amp;uid=&os=Linuxversion=25.2.5.0&coreVersion=qemu1%200.10.50">Found</a>
^
emulator: WARNING: UpdateCheck: failed to get the latest version, skipping check (current version '25.2.5-3567187')
UPDATE #2 After I successfully run the emulator and post my answer below, I fall to this problem again!! and my solution is not working anymore :( BTW I found another clue that I want to share it with you here. Following command is not starting to listen to the port as I mentioned before
android-sdk-linux/tools/emulator -avd test -no-snapshot-load -no-snapshot-save -no-window
But surprisingly, this command is running okey
android-sdk-linux/tools/qemu/linux-x86_64/qemu-system-x86_64 -avd test -no-snapshot-load -no-snapshot-save -no-window
I guess emulator
should run qemu-system-x86_64
but somewhere it makes some mistakes and run emulator64-x86
instead. Event after this finding I cannot figure out how to put this command in Android Emulator plugin
! So the question is open again.