UiAutomator exited unexpectedly with code 0, signal null [debug] [UiAutomator] Moving to state 'stopped'

I am trying to launch app but its shows black screen on emulator .

public void startAppium() throws Exception{

	  // Execute command string to start appium server.
	  p = Runtime.getRuntime().exec(cmd);
	  // Provide wait time of 10 mins to start appium server properly.
	  // If face any error(Could not start a new session...) then Increase
	  // this time to 15 or 20 mins.

// Thread.sleep(10000);
if (p != null) {
System.out.println(“Appium server Is started now.”);

	  }

	  DOMConfigurator.configure("log4j.xml");
      
      // Getting the Test Case name, as it will going to use in so many places
      // The main use is to get the TestCase row from the Test Data Excel sheet
      sTestCaseName = this.toString();
      // From above method we get long test case name including package and class name etc.
      // The below method will refine your test case name, exactly the name use have used
      sTestCaseName = Utils.getTestCaseName(this.toString());
      
      // Start printing the logs and printing the Test Case nme0
      Log.startTestCase(sTestCaseName);
      
      // Setting up the Test Data Excel file using Constants variables
      
      ExcelUtils.setExcelFile(Constant.Path_TestData + Constant.File_TestData,"Sheet1");
      
      // Fetching the Test Case row number from the Test Data Sheet
      // This row number will be feed to so many functions, to get the relevant data from the Test Data sheet
      iTestCaseRow = ExcelUtils.getRowContains(sTestCaseName,Constant.Col_TestCaseName);
      try {
     // File app = new File ("D:/Diro.apk");
	  DesiredCapabilities capabilities =  new DesiredCapabilities();
	  capabilities.setCapability("deviceName", "127.0.0.1:6555");

// capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “Android”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,“MobilePlatform.ANDROID”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION,“4.4.4”);

	capabilities.setCapability("appPackage", "com.whatsapp");
	capabilities.setCapability("appActivity", ".HomeActivity"); 
	capabilities.setCapability("noReset", true);
    capabilities.setCapability("fullReset", false);

// capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, “100”);
//capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
// Thread.sleep(1000);

	  AppiumDriverLocalService service = null;
      System.out.println("Starting Appium Service");
     
          service = new AppiumServiceBuilder().withCapabilities(capabilities)
              .withIPAddress("127.0.0.1")
              //.withArgument(GeneralServerFlag.SESSION_OVERRIDE)               
              .build();
          
          service.start();
          
         
  
          Assert.assertEquals(true, service.isRunning());
         
          driver = new AndroidDriver<MobileElement>(service, capabilities);
          ((AndroidDriver<MobileElement>) driver).launchApp();
        //  driver  = new AndroidDriver(new URL("http://127.0.0.1:4726/wd/hub") , capabilities);

// driver.manage().timeouts().implicitlyWait(180, TimeUnit.SECONDS);
driver.startActivity(“com.whatsapp”, “.HomeActivity”);
System.out.println(“Application launched successfully”);
Log.info(“Application launched successfully”);
Thread.sleep(50000L);
}
catch(Exception e){
// finally {
System.out.println(“dost”);
if (service != null) {
service.stop();
}
}

Logs —
[Appium] Welcome to Appium v1.5.3
[Appium] Non-default server args:
[Appium] address: ‘127.0.0.1’
[Appium] defaultCapabilities: { appPackage: ‘com.whatsapp’,
appActivity: ‘.HomeActivity’,
noReset: true,
platformVersion: ‘4.4.4’,
platformName: ‘MobilePlatform.ANDROID’,
deviceName: ‘127.0.0.1:6555’,
fullReset: false }
[Appium] Default capabilities, which will be added to each request unless overri
dden by desired capabilities:
[Appium] appPackage: ‘com.whatsapp’
[Appium] appActivity: ‘.HomeActivity’
[Appium] noReset: true
[Appium] platformVersion: ‘4.4.4’
[Appium] platformName: ‘MobilePlatform.ANDROID’
[Appium] deviceName: ‘127.0.0.1:6555’
[Appium] fullReset: false
[Appium] Appium REST http interface listener started on 127.0.0.1:4723
[HTTP] --> GET /wd/hub/status {}
[MJSONWP] Calling AppiumDriver.getStatus() with args: []
[MJSONWP] Responding to client with driver.getStatus() result: {“build”:{“versio
n”:“1.5.3”…
[HTTP] <-- GET /wd/hub/status 200 17 ms - 83
[HTTP] --> GET /wd/hub/status {}
[MJSONWP] Calling AppiumDriver.getStatus() with args: []
[MJSONWP] Responding to client with driver.getStatus() result: {“build”:{“versio
n”:“1.5.3”…
[HTTP] <-- GET /wd/hub/status 200 5 ms - 83
[HTTP] --> GET /wd/hub/status {}
[MJSONWP] Calling AppiumDriver.getStatus() with args: []
[MJSONWP] Responding to client with driver.getStatus() result: {“build”:{“versio
n”:“1.5.3”…
[HTTP] <-- GET /wd/hub/status 200 4 ms - 83
[HTTP] --> POST /wd/hub/session {“desiredCapabilities”:{“appPackage”:“com.whatsa
pp”,“appActivity”:".HomeActivity",“noReset”:true,“platformVersion”:“4.4.4”,“plat
formName”:“Android”,“deviceName”:“127.0.0.1:6555”,“fullReset”:false}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{“appPackage”:“com.wh
atsap…
[Appium] Creating new AndroidDriver session
[Appium] Capabilities:
[Appium] appPackage: ‘com.whatsapp’
[Appium] appActivity: ‘.HomeActivity’
[Appium] noReset: true
[Appium] platformVersion: ‘4.4.4’
[Appium] platformName: ‘Android’
[Appium] deviceName: ‘127.0.0.1:6555’
[Appium] fullReset: false
[BaseDriver] Session created with session id: 75272170-5cb5-4b56-bfa7-edcf5d00f0
77
[debug] [AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_121
[ADB] Checking whether adb is present
[ADB] Using adb.exe from C:\Users\Administrator\AppData\Local\Android\Sdk\platfo
rm-tools\adb.exe
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[AndroidDriver] Looking for a device with Android 4.4.4
[debug] [ADB] Setting device id to 127.0.0.1:6555
[ADB] Getting device platform version
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running C:\Users\Administrator\AppData\Local\Android\Sdk\platform-
tools\adb.exe with args: [”-P",5037,"-s",“127.0.0.1:6555”,“shell”,“getprop”,“ro.
build.version.release”]
[AndroidDriver] Using device: 127.0.0.1:6555
[ADB] Checking whether adb is present
[ADB] Using adb.exe from C:\Users\Administrator\AppData\Local\Android\Sdk\platfo
rm-tools\adb.exe
[debug] [ADB] Setting device id to 127.0.0.1:6555
[AndroidDriver] App file was not listed, instead we’re going to run com.whatsapp
directly on the device
[debug] [AndroidDriver] Checking whether package is present on the device
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running C:\Users\Administrator\AppData\Local\Android\Sdk\platform-
tools\adb.exe with args: ["-P",5037,"-s",“127.0.0.1:6555”,“shell”,“pm”,“list”,“p
ackages”,“com.whatsapp”]
[AndroidDriver] Starting Android session
[debug] [ADB] Running C:\Users\Administrator\AppData\Local\Android\Sdk\platform-
tools\adb.exe with args: ["-P",5037,"-s",“127.0.0.1:6555”,“wait-for-device”]
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running C:\Users\Administrator\AppData\Local\Android\Sdk\platform-
tools\adb.exe with args: ["-P",5037,"-s",“127.0.0.1:6555”,“shell”,“echo”,“ping”]

[debug] [Logcat] Starting logcat capture
[debug] [AndroidDriver] Pushing settings apk to device…
[debug] [ADB] Running C:\Users\Administrator\AppData\Local\Android\Sdk\platform-
tools\adb.exe with args: ["-P",5037,"-s",“127.0.0.1:6555”,“install”,“C:\Users\
Administrator\AppData\Roaming\npm\node_modules\appium\node_modules\appium
-android-driver\node_modules\io.appium.settings\bin\settings_apk-debug.apk”]

[debug] [AndroidDriver] Pushing unlock helper app to device…
[debug] [ADB] Running C:\Users\Administrator\AppData\Local\Android\Sdk\platform-
tools\adb.exe with args: ["-P",5037,"-s",“127.0.0.1:6555”,“install”,“C:\Users\
Administrator\AppData\Roaming\npm\node_modules\appium\node_modules\appium
-android-driver\node_modules\appium-unlock\bin\unlock_apk-debug.apk”]
[ADB] Getting device platform version
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running C:\Users\Administrator\AppData\Local\Android\Sdk\platform-
tools\adb.exe with args: ["-P",5037,"-s",“127.0.0.1:6555”,“shell”,“getprop”,“ro.
build.version.release”]
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running C:\Users\Administrator\AppData\Local\Android\Sdk\platform-
tools\adb.exe with args: ["-P",5037,"-s",“127.0.0.1:6555”,“shell”,“dumpsys”,“win
dow”]
[AndroidDriver] Screen already unlocked, doing nothing
[debug] [AndroidBootstrap] Watching for bootstrap disconnect
[debug] [ADB] Forwarding system: 4724 to device: 4724
[debug] [ADB] Running C:\Users\Administrator\AppData\Local\Android\Sdk\platform-
tools\adb.exe with args: ["-P",5037,"-s",“127.0.0.1:6555”,“forward”,“tcp:4724”,"
tcp:4724"]
[debug] [UiAutomator] Starting UiAutomator
[debug] [UiAutomator] Moving to state ‘starting’
[debug] [UiAutomator] Parsing uiautomator jar
[debug] [UiAutomator] Found jar name: ‘AppiumBootstrap.jar’
[debug] [ADB] Running C:\Users\Administrator\AppData\Local\Android\Sdk\platform-
tools\adb.exe with args: ["-P",5037,"-s",“127.0.0.1:6555”,“push”,“C:\Users\Adm
inistrator\AppData\Roaming\npm\node_modules\appium\node_modules\appium-an
droid-driver\node_modules\appium-android-bootstrap\bootstrap\bin\AppiumBoot
strap.jar”,"/data/local/tmp/"]
[debug] [ADB] Attempting to kill all uiautomator processes
[debug] [ADB] Getting all processes with uiautomator
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running C:\Users\Administrator\AppData\Local\Android\Sdk\platform-
tools\adb.exe with args: ["-P",5037,"-s",“127.0.0.1:6555”,“shell”,“ps”,“uiautoma
tor”]
[ADB] No uiautomator process found to kill, continuing…
[debug] [UiAutomator] Starting UIAutomator
[debug] [ADB] Creating ADB subprocess with args: -P, 5037, -s, 127.0.0.1:6555, s
hell, uiautomator, runtest, AppiumBootstrap.jar, -c, io.appium.android.bootstrap
.Bootstrap, -e, pkg, com.whatsapp, -e, disableAndroidWatchers, false, -e, accept
SslCerts, false
[UiAutomator] UiAutomator exited unexpectedly with code 0, signal null
[debug] [UiAutomator] Moving to state ‘stopped’

Can any one please suggest me , what i am doing wrong ??..

Hi

I am getting the same error now when I run my appium tests connected to android device. It was working fine few days ago… Kindly help in resolving the issue…

Regards
Vaishnavi

1 Like

Check path for appium.js and node and increase time for launch apk

I have the same issue. I’m using docker image (appium/appium) with appium versión 1.7.2.