Jenkins: how do you get deviceId using the Android Emulator Plugin


Now I have a Test Suites running on Jenkins, how do I get deviceId?



Hi @roy.zheng,

For me, the Android emulator device id, you can run the command adb devices, which will return you a list of the running emulators.

The device id seems to be emulator- plus the port number the emulator is running on. For me, it’s always running on port 5554, so my device id is always emulator-5554.

Hope this helps,



thank you @Chris_Trevarthen .
I try, but it prompts me “No mobile device with name ‘emulator-5786’ available”.

In addition, I also want to know how to make the emulator port always 5786


Hi @roy.zheng,

That does seem weird that the device is created but then can’t be found. Could you share the Android Emulator Plugin settings you’re using?

As for using a specific port, the Android Emulator Plugin docs say that it will be a random port every time. However, you might be able to use the Jenkins Port Allocator Plugin to set a value for the port:

Hope this helps,



thank you @Chris_Trevarthen


Hi @roy.zheng,

Are you able to turn on the “Show emulator window” setting? I’m wondering if Katalon running on CI is having a problem because there is no graphical representation of the device.

– Chris


thank you @Chris_Trevarthen ,
I turn on the Show emulator window, but the emulator does not work properly.


Hi @roy.zheng,

That makes sense if there’s no display hooked up to the build node.

I’ve also seen similar issues to what you’re seeing when I didn’t run the startApplication() command at the beginning of the test. Could you share the code of the first test in your test suite?

– Chris


@Chris_Trevarthen Of course,
StartApplication () has the wrong appFile and I know it.

Mobile.startApplication('C:\\Users\\User\\Desktop\\debug0410.apk', false)
def timeout = GlobalVariable.g_Mobile_TimeOut
' need to log in ?'
if(Mobile.waitForElementPresent(findTestObject('android_V1/Login/Button_Sign in'), GlobalVariable.g_waitForElementTime)){
	def g_ServerAddress = GlobalVariable.g_ServerAddress

	'server is correct? or Switch servers'
	if (Mobile.getAttribute(findTestObject('android_V1/Login/Text_ServerName'), 'text', timeout) != g_ServerAddress) {
	    Mobile.tap(findTestObject('android_V1/Login/Text_ServerName'), timeout)
		def serverAddress = GlobalVariable.g_ServerAddress
	    Mobile.tap(findTestObject('android_V1/Login/CheckedText_serverAddress',[('serverAddress'):serverAddress]), timeout)
	    Mobile.tap(findTestObject('android_V1/Login/button_ok'), timeout)
	Mobile.setText(findTestObject('android_V1/Login/EditText_Account'), GlobalVariable.g_username, timeout)
	Mobile.setText(findTestObject('android_V1/Login/EditText_Password'), GlobalVariable.g_password, timeout)
	Mobile.tap(findTestObject('android_V1/Login/Button_Sign in'), timeout)



Hi @roy.zheng,

Ah yes, if you’re not running startApplication() at all or running it with a non-existent .apk file, I’m pretty sure that you get the exact error you’re seeing. It definitely isn’t very obvious about what’s really going on.

So, if you point to an actual .apk located on the Jenkins build node, in the startApplication() call, I bet you’ll get further in your test.

Also check out this post that can help you avoid hardcoding the .apk file path in your scripts so it’ll be easier to run on Jenkins:

Hope this helps,



thank you @Chris_Trevarthen
I think reading your article later will be very helpful to me, but I want to solve the problem first.
I tried to make the.apk file exist, but the emulator still doesn’t work


Hi @roy.zheng,

That startApplication code in your test looks right. It’s odd that it’s still failing. I assume that you turned off the checkbox for “Show emulator window” again?

The only other thing that comes to mind is that you might need to move the “startApplication” into the Test Suite itself. So taking it out of the Test Case file and having it as the setup step of the Test Suite script.



thank you @Chris_Trevarthen,
I turned on the “Show emulator window”.
Move the “startApplication" in the test suite itself?How to?


Hi @roy.zheng,

First, let’t try turning off the “Show emulator window” again, because I don’t think your Jenkins node has a display on it and that could cause the emulator not to start. After you’ve done that, try running the tests again, making sure you have the startApplication() function using the correct path to the file: /data/jenkins/workspace/Mobile_V1/debug0410.apk.

If that doesn’t work, my suggestion to put the startApplication() function in the Test Suite would mean:

  • Open the Test Suites/mobile_test file in Katalon
  • Switch to the “Script” view tab at the bottom
  • In the function for @SetUp, change it to the following:
    @SetUp(skipped = false) // Please change skipped to be false to activate this method.
    def setUp() {
        Mobile.startApplication('/data/jenkins/workspace/Mobile_V1/debug0410.apk', false)
  • This will start the mobile app once before the whole suite starts, not for each test
  • Remove the startApplication() line from your Test Case file
  • Rerun your test on Jenkins

This will mean that you can’t run the individual Test Cases any more - you’ll need to run them through a Test Suite. There are ways around this, but for right now, we should just see if we can get the Test Suite working.

Hope this helps,