Android Driver getting shutdown Automatically

Hi,

Appium : 1.5.3

I have started Appium through CLI.

appium --default-capabilities “{“platformName”:“ANDROID”,“platformVersion”:“4.4.2”,“deviceName”:“192.168.56.101:5555”,“udid”:“192.168.56.101:5555”,“newCommandTimeout”: 8000}” -a 127.0.0.1 -p 4723 --nodeconfig ~/Backup/Learning/Appium\ with\ Selenium\ Grid/appium_node_S4.json --no-reset --session-override

However after executing once the testscript completes after few seconds the appium server shows following logs

Script :

package Sample;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class NewTest {

@Parameters({“deviceN”,“Version”})
@Test //(threadPoolSize = 3, invocationCount = 6, timeOut = 1000)
public void test_method1(String deviceN, String deviceVersion) throws MalformedURLException,Exception {

  DesiredCapabilities cap = new DesiredCapabilities();
  cap.setCapability("deviceName", deviceN);
  cap.setCapability("platformVersion", deviceVersion);
  cap.setCapability("appPackage", "io.appium.android.apis");
  cap.setCapability("appActivity", "ApiDemos");
  cap.setCapability("platformName", "ANDROID");
  
  System.out.println("Working on device" + deviceN + " version " + deviceVersion);
  AndroidDriver<AndroidElement>driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"),cap);
  
  
  Thread.sleep(5000);

// driver.quit();
driver.closeApp();
// driver.closeApp();
}

}

Appium server logs shows following -

MJSONWP] Calling AppiumDriver.getStatus() with args: []
[MJSONWP] Responding to client with driver.getStatus() result: {“build”:{“version”:“1.5.3”…
[HTTP] <-- GET /wd/hub/status 200 15 ms - 121
[HTTP] --> GET /wd/hub/status {}
[MJSONWP] Calling AppiumDriver.getStatus() with args: []
[MJSONWP] Responding to client with driver.getStatus() result: {“build”:{“version”:“1.5.3”…
[HTTP] <-- GET /wd/hub/status 200 13 ms - 121
[HTTP] --> GET /wd/hub/status {}
[MJSONWP] Calling AppiumDriver.getStatus() with args: []
[MJSONWP] Responding to client with driver.getStatus() result: {“build”:{“version”:“1.5.3”…
[HTTP] <-- GET /wd/hub/status 200 11 ms - 121
[HTTP] --> GET /wd/hub/status {}
[MJSONWP] Calling AppiumDriver.getStatus() with args: []
[MJSONWP] Responding to client with driver.getStatus() result: {“build”:{“version”:“1.5.3”…
[HTTP] <-- GET /wd/hub/status 200 29 ms - 121
[HTTP] --> GET /wd/hub/status {}
[MJSONWP] Calling AppiumDriver.getStatus() with args: []
[MJSONWP] Responding to client with driver.getStatus() result: {“build”:{“version”:“1.5.3”…
[HTTP] <-- GET /wd/hub/status 200 24 ms - 121
[HTTP] --> DELETE /wd/hub/session/2582ff43-da8a-4ad9-b0f7-d713a90b206e {}
[MJSONWP] Calling AppiumDriver.deleteSession() with args: [“2582ff43-da8a-4ad9-b0f7-d…
[debug] [AndroidDriver] Shutting down Android driver
[debug] [ADB] Getting connected devices…
[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running /Users/z/Backup/Softwares/android-sdk-macosx/platform-tools/adb with args: [”-P",5037,"-s",“192.168.56.101:5555”,“shell”,“am”,“force-stop”,“io.appium.android.apis”]
[debug] [ADB] Getting connected devices…
[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running /Users/z/Backup/Softwares/android-sdk-macosx/platform-tools/adb with args: ["-P",5037,"-s",“192.168.56.101:5555”,“shell”,“am”,“force-stop”,“io.appium.unlock”]
[debug] [ADB] Pressing the HOME button
[debug] [ADB] Getting connected devices…
[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running /Users/z/Backup/Softwares/android-sdk-macosx/platform-tools/adb with args: ["-P",5037,"-s",“192.168.56.101:5555”,“shell”,“input”,“keyevent”,3]
[debug] [Logcat] Stopping logcat capture
[debug] [AndroidBootstrap] Sending command to android: {“cmd”:“shutdown”}
[HTTP] --> GET /wd/hub/status {}
[MJSONWP] Calling AppiumDriver.getStatus() with args: []
[UiAutomator] UiAutomator exited unexpectedly with code 0, signal null
[debug] [UiAutomator] Moving to state ‘stopped’

I have no option to restart the Appium server for the script to work next time.
Any idea how to make script rerun without restarting appium server and not to pull down the android driver

Hi,

cap.setCapability(“platformName”, “ANDROID”);
–> Can you change to … “Android”);

AndroidDriverdriver = new AndroidDriver<>(new URL(“http://127.0.0.1:4723/wd/hub”),cap);
–> Can you change to: AndroidDriver driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”),cap);

driver.closeApp();
–> What does this do?

–> Can you change to: AndroidDriver driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”),cap);

This change gives me warning

Multiple markers at this line
- AndroidDriver is a raw type. References to generic type AndroidDriver should be
parameterized
- AndroidDriver is a raw type. References to generic type AndroidDriver should be
parameterized

driver.closeApp() is actually killing the session smoothly , .quit() doesnt even close the app
.close() doesnt work too

So strange to me, I have never faced that before…