Mobile Tests fail when an Android Emulator has already been running for a while, the first test fails and need to reboot the emulator again

Before hitting that Ask the Community button, make sure to:

  • Search for similar topics to make sure it hasn’t been reported by another member;
  • Assign suitable tags to your topics (e.g. katalon-studio, web-testing, chrome, etc.)
  • Encourage other members to Vote on your topic so that we can prioritize your issue(s)!
  • And most importantly, try to follow the template below. :smiley:

User information
In case of License issue, please provide : accountID, account owner email address

*Summary

*Steps to reproduce
Start Android Emulator and keep it running, usually for a few hours or so

Run the Mobile Katalon tests

First Test fails. The next test onwards passes.

This does not happen always

*Expected Results

*Actual Results

*Screenshots / Videos
(please attach screenshots or videos if necessary to reproduce the issue)

*Blocker?
Yes/No

Number of affected users?
The whole number of users you think might be affected


*Operating System
e.g. Windows 10/11 or MacOS Montery

*Katalon Studio version
e.g. version 8.x.x

*Katalon Studio logs
Windows logs folder: Katalon Studio folder>\config\.metadata\.log
MacOS logs folder: file:///Applications/Katalon%20Studio.app/Contents/MacOS/config/.metadata/.plugins/org.eclipse.ui.workbench/log

Environment (for Web Testing)
Browser & browser version

Environment (for Mobile Testing)
Browser and Browser version

Environment (for Mobile testing)

Appium version

Mobile platform/version under test: (for example: iOS 11 or Android 7)

Real device or emulator/simulator: (for example: iPhone 6s real or Nexus 6 simulator)

Xcode version (for iOS): (for example: Xcode 8 or Xcode 11)

Appium Logs: \.appium

Application file (.apk/.ipa): (if possible)

2 Likes

Hi @geetha,

Welcome to our community. Thank you for sharing your issue.

I am not sure if I can understand clearly what you mean, can you please add screenshot or explain clearer steps to reproduce, expected result, …? Thank you

To resolve Android emulator instability:

  1. Pre-Test Cleanup

kotlin

// Attach to Test Suite Startup
MobileDriverFactory.startMobileExecution()
def deviceDriver = MobileDriverFactory.getDeviceDriver()
deviceDriver.biResetAppLayout() // Clear app UI
deviceDriver.biDisableAnimations() // Reduce rendering load
deviceDriver.biClearCache('YOUR_APP_PACKAGE') // Wipe session
  1. Optimize Appium Config
    Update appium-settings.gradle:

groovy

additionalCapabilities = [
    'newCommandTimeout': '120', // Extend timeouts
    'ignoreUnimportantViews': 'true', // Skip trivial elements
    'udid': 'emulator-5554', // Explicit device ID
    'automationName': 'uiautomator2' // Better touch handling
]
  1. Emulator Tuning
  • Reduce RAM to 4-6GB (via AVD Manager)
  • Enable ARM Architecture (faster execution)
  1. Test-Specific Delays

kotlin

MobileElement element = MobileHelper.waitForElementPresent(By.id('ID'), 45)
MobileDriverFactory.getDeviceDriver().touchAction().tap(element).perform()
System.sleep(500) // Add delay after critical actions
  1. Deep Dive Analysis
    Review katalon.log for patterns:

bash

# Check for these errors
grep -E 'ANR|DeviceUnlocked|connect ECONNREFUSED' Katalon.log

Expected Outcome
After implementation:
✓ First test passes consistently
✓ Emulator remains stable under sustained use
✓ Resource leaks/ ANRs reduced

1 Like