Appium closes instantly when finding multiple elements

Hi,

I am using Appium for Native App and the appium server closes the app and closes the session when trying to finding multiple elements for count or something else from the device. I have updated to version 1.2.4 in which UiSelector has updated successfully to find the appropriate elements. Even though I am having this App closing issue. My server log looks like:

info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:"//[@class
=‘android.widget.LinearLayout’]/
[@class=‘android.widget.LinearLayout’]/[@class=‘android.widget.LinearLayout’][1]/[@class=‘android.widget
.ImageView’]",“context”:"",“multiple”:true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //[@class=‘android.widget.LinearLayout’]/[@class=‘android.widget.LinearLayout’]/[@class=‘andro
id.widget.LinearLayout’][1]/
[@class=‘android.widget.ImageView’] using XPATH with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.ImageView, INSTANCE=1]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.ImageView, INSTANCE=1]
info: [debug] [BOOTSTRAP] [debug] Selector ends with instance.
info: [debug] Didn’t get a new command in 35 secs, shutting down…
info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] executing: “C:\adt-bundle-windows-x86-20140702\sdk\platform-tools\adb.exe” -s 192.168.3.55:5555 shell “input keyevent 3”
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
warn: Trying to run a command when one is already in progress. Will spin a bit and try again
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.ImageView, INSTANCE=2]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.ImageView, INSTANCE=2]
info: [debug] [BOOTSTRAP] [debug] Selector ends with instance.
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.ImageView, INSTANCE=3]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.ImageView, INSTANCE=3]
info: [debug] [BOOTSTRAP] [debug] Selector ends with instance.
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:[{“ELEMENT”:“46”},{“ELEMENT”:“47”},{“ELEMENT”:“48”}],“status”:0}
info: [debug] Responding to client with success: {“status”:0,“value”:[{“ELEMENT”:“46”},{“ELEMENT”:“47”},{“ELEMENT”:“48”}],“sessionId”:“1f30
4b7a-5120-4485-a6cf-f47e05818df9”}
info: <-- POST /wd/hub/session/1f304b7a-5120-4485-a6cf-f47e05818df9/elements 200 37700.121 ms - 124 {“status”:0,“value”:[{“ELEMENT”:“46”},{
“ELEMENT”:“47”},{“ELEMENT”:“48”}],“sessionId”:“1f304b7a-5120-4485-a6cf-f47e05818df9”}
info: --> POST /wd/hub/session/1f304b7a-5120-4485-a6cf-f47e05818df9/element {“using”:“xpath”,“value”:"//[@class=‘android.widget.LinearLayo
ut’]/
[@class=‘android.widget.LinearLayout’]/[@class=‘android.widget.LinearLayout’][1]/[@class=‘android.widget.ImageView’][2]"}
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“xpath”,“selector”:"//[@class=‘android.widget.LinearLayout’]/[@cl
ass=‘android.widget.LinearLayout’]/[@class=‘android.widget.LinearLayout’][1]/[@class=‘android.widget.ImageView’][2]",“context”:"",“multip
le”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“shutdown”}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:“OK, shutting down”,“status”:0}
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 107.668
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] We shut down because no new commands came in
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“xpath”,“selector”:"//[@class=‘android.widget.LinearLayout’]/[@cl
ass=‘android.widget.LinearLayout’]/[@class=‘android.widget.LinearLayout’][1]/[@class=‘android.widget.ImageView’][2]",“context”:"",“multip
le”:false}]

Here, it should get the list of elements and select a random element from that and it fails there frequently.

Is anyone facing this kind of issue? Kindly help to resolve it.