[FIXED] Start android emulator adb from Jenkins in windows (run instrumented tests, emulator does not appear)

Issue

I would like to start emulator from Jenkins to test Android app. This is my setup of the project in jenkins and console output:

setup and output

When I tried Jenkins android emulator plugin with existing emulator device and his name, setup and output is here: Jenkins emulator plugin setup and console output

The build is successful, but I cant see the running emulator when testing is running.

Strange thing of these two options is, that when I start the command line and type these two commands, the emulator is always shown and it is running normally. But from Jenkins, in the second option I cant see it. And first option is stuck. See the screens please.

Can somebody help me with some advice? I have tried many options and I cant figure it out.

Many thanks 🙂

P.S.: Here are the output texts (in case that somebody would like to copy it)

1)

C:\Program Files (x86)\Jenkins\workspace\Android Sandbox>C:\Users\josef\AppData\Local\Android\Sdk/tools/emulator -avd Nexus_4_API_22 -accel auto 
emulator: WARNING: encryption is off
Hax is enabled
Hax ram_size 0x40000000
HAX is working and emulator runs in fast virt mode.

2)

$ C:\Users\josef\AppData\Local\Android\Sdk/tools/android.bat list target
[android] Using Android SDK: C:\Users\josef\AppData\Local\Android\Sdk
$ C:\Users\josef\AppData\Local\Android\Sdk/platform-tools/adb.exe start-server
* daemon not running. starting it now at tcp:5824 *
* daemon started successfully *
$ C:\Users\josef\AppData\Local\Android\Sdk/platform-tools/adb.exe start-server
[android] Starting Android emulator
[android] Erasing existing emulator data...
$ C:\Users\josef\AppData\Local\Android\Sdk/tools/emulator.exe -engine classic -ports 5684,5685 -report-console tcp:5845,max=60 -avd Nexus_4_API_22 -no-snapshot-load -no-snapshot-save -wipe-data -engine auto
emulator: WARNING: encryption is off
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
Hax is enabled
Hax ram_size 0x40000000
HAX is working and emulator runs in fast virt mode.
emulator: WARNING: Requested adb port (5685) is outside the recommended range [5555,5586]. ADB may not function properly for the emulator. See -help-port for details.
[android] Emulator reported that the console is available on port 5 684
[android] Waiting for emulator to finish booting...
$ C:\Users\josef\AppData\Local\Android\Sdk/platform-tools/adb.exe -s emulator-5684 wait-for-device shell getprop init.svc.bootanim
[android] Emulator reported that the startup process is 'running'
$ C:\Users\josef\AppData\Local\Android\Sdk/platform-tools/adb.exe -s emulator-5684 wait-for-device shell getprop init.svc.bootanim
[android] Emulator reported that the startup process is 'stopped'
$ C:\Users\josef\AppData\Local\Android\Sdk/platform-tools/adb.exe -s emulator-5684 logcat -v time
[android] Emulator is ready for use (took 31 seconds)
[Gradle] - Launching build.
[Android Sandbox] $ cmd.exe /C '""C:\Program Files (x86)\Jenkins\workspace\Android Sandbox\gradlew.bat"' clean connectedAndroidTest && exit %%ERRORLEVEL%%"
Starting a Gradle Daemon, 2 incompatible and 5 stopped Daemons could not be reused, use --status for details
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to C:\Users\josef\AppData\Local\Android\Sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

Solution

I recommend using the command lines instead of Android Emulator Plugin. This article is helpful

Answered By – Testujaca Malpeczka

Answer Checked By – Robin (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published