Android UIAutomator shutdown unexpectedly

Hi, I am using Appium java client and js library to build an automated testing system. The testing process lasts many hours, but UIAutomator always shuts down unexpectedly during the process. The server log is as follows:

[debug] [ADB] Getting connected devices…
[MJSONWP] Encountered internal error running command: Error: UiAutomator shut down unexpectedly
at AndroidBootstrap.callee$2$0$ (lib/bootstrap.js:76:44)
at tryCatch (/home/autotest/node-v5.8.0-linux-x64/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/home/autotest/node-v5.8.0-linux-x64/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/home/autotest/node-v5.8.0-linux-x64/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/home/autotest/node-v5.8.0-linux-x64/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/home/autotest/node-v5.8.0-linux-x64/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at new Promise (/home/autotest/node-v5.8.0-linux-x64/lib/node_modules/appium/node_modules/core-js/library/modules/es6.promise.js:197:7)
at AsyncIterator.enqueue (/home/autotest/node-v5.8.0-linux-x64/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/home/autotest/node-v5.8.0-linux-x64/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/home/autotest/node-v5.8.0-linux-x64/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at UiAutomator.callee$2$0 (lib/bootstrap.js:73:64)
at emitOne (events.js:90:13)
at UiAutomator.emit (events.js:182:7)
at UiAutomator.changeState (lib/uiautomator.js:85:10)
at SubProcess. (lib/uiautomator.js:47:14)
at emitTwo (events.js:100:13)
at SubProcess.emit (events.js:185:7)
at ChildProcess. (lib/teen_process.js:186:14)
at emitTwo (events.js:100:13)
at ChildProcess.emit (events.js:185:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
[HTTP] ← POST /wd/hub/session/ff6d7bc5-c50a-4ac9-8015-1c1a3cba50c8/element 500 1122 ms - 205
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /home/autotest/Android/Sdk/platform-tools/adb with args: [“-P”,5037,“-s”,“emulator-5554”,“shell”,“am”,“force-stop”,“com.test.automation”]

Appium js: 1.5.3
nodejs : v5.8.0
java client: 3.4.1

Any ideas? Thank you.

If you are running your tests on an Android device or emulator then check the version of Android OS on it.
Appium only supports Android SDK API >= 17. (

I had got the same error (UiAUtomator shut down unexpectedly) when I ran my tests on a device that was running on Android API 16.

It might be the same error. But my testing cases were running on emulator Android 4.4. I found it was the appium nodejs problem, since it would not do garbage collection automatically. So I solved the problem by setting the max_old_space_size to 8G.:grinning:

@chyi13 - I also faced this problem. Can you help me how did you solve this problem? Where did you set max_old_space_size to 8G?

It is the place where Appium starts its nodejs server. I am using Java-client server. And I edit the Just add “–max-old-space-size=8192” to nodeJSArgs. :relaxed:

Hi @chyi13, Could you please let me know where I can find file and where I need to add “–max-old-space-size=8192”?

You could find it in Appium github repo.