Application gets force closed automatically when script is running(Android)

Hi Friends,

While executing the script(test cases) in Appium(Java), the application gets force closed automatically in a scenario in the device(and then script keeps on waiting for the next element to be found & fails after the timeout of the wait). Whereas if I execute the same scenario manually in the same app, the application doesn’t get force closed. i.e., App works fine manually, but while executing the same scenario from Appium force closes the app.

Could anyone help me to solve this issue???

I’m using
Appium - 1.4.16.1
Eclipse Luna - 4.4.0
Android - 4.4.2(KitKat)
Java - 1.8.0_73

Hi Mohamed_Ashik
Could you possibly share the appium.log?

Here the log for the issue where the last Click action gets executed, the later app gets force closed in device & Appium keeps on waiting for the alert message.

2016-09-07 07:48:15:126 - info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
2016-09-07 07:48:15:126 - info: [debug] [BOOTSTRAP] [debug] Got command action: getAttribute
2016-09-07 07:48:15:158 - info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:“true”,“status”:0}
2016-09-07 07:48:15:159 - info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“3a20fde2-fbca-47db-a791-d383190d527b”}
2016-09-07 07:48:15:159 - info: <-- GET /wd/hub/session/3a20fde2-fbca-47db-a791-d383190d527b/element/79/displayed 200 36.765 ms - 76 {“status”:0,“value”:true,“sessionId”:“3a20fde2-fbca-47db-a791-d383190d527b”}
2016-09-07 07:48:15:161 - info: --> POST /wd/hub/session/3a20fde2-fbca-47db-a791-d383190d527b/element/79/click {“id”:“79”}
2016-09-07 07:48:15:161 - info: [debug] Pushing command to appium work queue: [“element:click”,{“elementId”:“79”}]
2016-09-07 07:48:15:164 - info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:click”,“params”:{“elementId”:“79”}}
2016-09-07 07:48:15:165 - info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
2016-09-07 07:48:15:166 - info: [debug] [BOOTSTRAP] [debug] Got command action: click
2016-09-07 07:48:15:515 - info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:true,“status”:0}
2016-09-07 07:48:15:515 - info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“3a20fde2-fbca-47db-a791-d383190d527b”}
2016-09-07 07:48:15:516 - info: <-- POST /wd/hub/session/3a20fde2-fbca-47db-a791-d383190d527b/element/79/click 200 354.722 ms - 76 {“status”:0,“value”:true,“sessionId”:“3a20fde2-fbca-47db-a791-d383190d527b”}
2016-09-07 07:48:15:520 - info: --> POST /wd/hub/session/3a20fde2-fbca-47db-a791-d383190d527b/element {“using”:“id”,“value”:“android:id/alertTitle”}
2016-09-07 07:48:15:520 - info: [debug] Waiting up to 15000ms for condition
2016-09-07 07:48:15:521 - info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“id”,“selector”:“android:id/alertTitle”,“context”:"",“multiple”:false}]
2016-09-07 07:48:15:525 - info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“android:id/alertTitle”,“context”:"",“multiple”:false}}
2016-09-07 07:48:15:525 - info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
2016-09-07 07:48:15:525 - info: [debug] [BOOTSTRAP] [debug] Got command action: find
2016-09-07 07:48:15:526 - info: [debug] [BOOTSTRAP] [debug] Finding android:id/alertTitle using ID with the contextId: multiple: false
2016-09-07 07:48:15:526 - info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=android:id/alertTitle]
2016-09-07 07:48:16:063 - info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
2016-09-07 07:48:16:064 - info: [debug] [BOOTSTRAP] [debug] Finding android:id/alertTitle using ID with the contextId: multiple: false
2016-09-07 07:48:16:064 - info: [debug] [BOOTSTRAP] [debug] Using:

Hi, I would like to have the screen captured for both before/after this element: android:id/alertTitle

Hi TuHuynh,

I’m sorry to say you that sharing of the screen shot of our application is prohibited. But I could explain you the exact scenario & tell you about the error we face.

  1. When the element (id:79) is successfully clicked
  2. The app gets closed automatically & we get a pop-up saying “Unfortunately, application_name has stopped” with an ok button in it.
  3. After this script waits for the alert message as mentioned in log & fails after 15 sec.

I see…

  1. Try to close the app on Mobile completely > Restart your Mobile
  2. In the script, try to add a hard-wait about 5 seconds before doing click and about 5 seconds after doing click.
    p.s: hard-wait is not a solution, just troubleshooting around the issue to narrow down it.

Stucked with same problem ! Any other solution?

With android enable on phone in developer menu show touches and coordinates. This helps to see if you tap accidently on close app button in code.

Hello @Aleksei still not working

We know. But only you can find reason of it. It can be accidental tap in your code or some app issue.