Script runs fine on Android 5.1, gives "UiAutomator exited unexpectedly with code 0, signal null" in higher versions

Hi there,

I am running below script on real device to launch website on chrome.
(Env details -
Android Studio - 2.3.1
Selenium - 3.3.1
TestNG - 6.9.10
Appium - 1.6.4)

WebDriver driver;
@Before
public void setUp() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“deviceName”, “Moto G”);
capabilities.setCapability(“newCommandTimeout”, 120);
//capabilities.setCapability(“chromedriverExecutable”, “C://Users//Eclipse//Drivers//chromedriver.exe”);
capabilities.setCapability(CapabilityType.BROWSER_NAME, “Chrome”);
capabilities.setCapability(“launchTimeout”, “100000”);
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(CapabilityType.VERSION, “5.1”);
//capabilities.setCapability(“appPackage”, “com.android.launcher”);
//capabilities.setCapability(“appActivity”, “com.google.android.apps.chrome.Main”);
driver = new RemoteWebDriver(new URL(“http://0.0.0.0:4723/wd/hub”), capabilities);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
driver.navigate().to(“http://www.google.com”);
System.out.println(“Android Device browser launched successfully”);
}

This script runs fine on Moto G, Android 5.1, API level 22, test completes successfully. However, when I try to run this on Samsung Galaxy S7 - Android 6.0.1 and Samsung Galaxy S8+ - Android 7.0, the Gradle build completes successfully but test doesn’t launch and Appium server (1.6.4) gives error. Please find complete error logs below -

[HTTP] --> POST /wd/hub/session {“capabilities”:[{“desiredCapabilities”:{“newCommandTimeout”:120,“browserName”:“Chrome”,“platformName”:“Android”,“deviceName”:“988919445333384831”,“launchTimeout”:“100000”,“version”:“7.0”}},{“requiredCapabilities”:{}}],“desiredCapabilities”:{“newCommandTimeout”:120,“browserName”:“Chrome”,“platformName”:“Android”,“deviceName”:“988919445333384831”,“launchTimeout”:“100000”,“version”:“7.0”},“requiredCapabilities”:{}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{“newCommandTimeout”:120,“browserName”:“Chrome”,“platformName”:“Android”,“deviceName”:“988919445333384831”,“launchTimeout”:“100000”,“version”:“7.0”},{},[{“desiredCapabilities”:{“newCommandTimeout”:120,“browserName”:“Chrome”,“platformName”:“Android”,“deviceName”:“988919445333384831”,“launchTimeout”:“100000”,“version”:“7.0”}},{“requiredCapabilities”:{}}],null,null]
[BaseDriver] Event ‘newSessionRequested’ logged at 1493691609437 (22:20:09 GMT-0400 (Eastern Daylight Time))
[Appium] Creating new AndroidDriver (v1.17.1) session
[Appium] Capabilities:
[Appium] newCommandTimeout: 120
[Appium] browserName: ‘Chrome’
[Appium] platformName: ‘Android’
[Appium] deviceName: ‘988919445333384831’
[Appium] launchTimeout: ‘100000’
[Appium] version: ‘7.0’
[AndroidDriver] AndroidDriver version: 1.17.1
[BaseDriver] The following capabilities were provided, but are not recognized by appium: launchTimeout, version.
[BaseDriver] Session created with session id: 56a0f2e8-6079-45c9-a7aa-8c0a2f754255
[AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_121
[AndroidDriver] We’re going to run a Chrome-based session
[AndroidDriver] Chrome-type package and activity are com.android.chrome and com.google.android.apps.chrome.Main
[ADB] Checking whether adb is present
[ADB] Using adb.exe from C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[AndroidDriver] Using device: 988919445333384831
[ADB] Checking whether adb is present
[ADB] Using adb.exe from C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe
[ADB] Setting device id to 988919445333384831
[AndroidDriver] App file was not listed, instead we’re going to run com.android.chrome directly on the device
[AndroidDriver] Checking whether package is present on the device
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“pm”,“list”,“packages”,“com.android.chrome”]
[AndroidDriver] Starting Android session
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“wait-for-device”]
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“echo”,“ping”]
[Logcat] Starting logcat capture
[AndroidDriver] Pushing settings apk to device…
[ADB] Getting install status for io.appium.settings
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“pm”,“list”,“packages”,“io.appium.settings”]
[ADB] App is installed
[ADB] Getting package info for io.appium.settings
[ADB] Getting connected devices…
[ADB] Checking whether aapt is present
[ADB] Using aapt.exe from C:\Users\SDSA\AppData\Local\Android\sdk\build-tools\25.0.2\aapt.exe
[ADB] Cannot read version codes of C:\Users\SDSA\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\io.appium.settings\app\build\outputs\apk\settings_apk-debug.apk and/or io.appium.settings. Assuming correct app version is already installed
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“dumpsys”,“package”,“io.appium.settings”]
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“getprop”,“ro.build.version.sdk”]
[ADB] Device API level: 24
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“dumpsys”,“package”,“io.appium.settings”]
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“pm”,“dump”,“io.appium.settings”]
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“pm”,“grant”,“io.appium.settings”,“android.permission.WRITE_SETTINGS”,";",“pm”,“grant”,“io.appium.settings”,“android.permission.ACCESS_MOCK_LOCATION”,";"]
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“pm”,“grant”,“io.appium.settings”,“android.permission.WRITE_SETTINGS”,";",“pm”,“grant”,“io.appium.settings”,“android.permission.ACCESS_MOCK_LOCATION”,";"]
[AndroidDriver] Pushing unlock helper app to device…
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“install”,“C:\Users\SDSA\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-unlock\bin\unlock_apk-debug.apk”]
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“install”,“C:\Users\SDSA\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-unlock\bin\unlock_apk-debug.apk”]
[ADB] Application ‘C:\Users\SDSA\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-unlock\bin\unlock_apk-debug.apk’ already installed. Continuing.
[ADB] Device API level: 24
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“appops”,“set”,“io.appium.settings”,“android:mock_location”,“allow”]
[ADB] Getting device platform version
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“getprop”,“ro.build.version.release”]
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“wm”,“size”]
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“getprop”,“ro.product.model”]
[ADB] Current device property ‘ro.product.model’: SM-G955U
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“getprop”,“ro.product.manufacturer”]
[ADB] Current device property ‘ro.product.manufacturer’: samsung
[AndroidDriver] No app sent in, not parsing package/activity
[AndroidDriver] No app capability. Assuming it is already on the device
[AndroidDriver] Running fast reset (stop and clear)
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“am”,“force-stop”,“com.android.chrome”]
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“pm”,“clear”,“com.android.chrome”]
[AndroidBootstrap] Watching for bootstrap disconnect
[ADB] Forwarding system: 4724 to device: 4724
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“forward”,“tcp:4724”,“tcp:4724”]
[UiAutomator] Starting UiAutomator
[UiAutomator] Moving to state ‘starting’
[UiAutomator] Parsing uiautomator jar
[UiAutomator] Found jar name: ‘AppiumBootstrap.jar’
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“push”,“C:\Users\SDSA\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-android-bootstrap\bootstrap\bin\AppiumBootstrap.jar”,"/data/local/tmp/"]
[ADB] Attempting to kill all uiautomator processes
[ADB] Getting all processes with uiautomator
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\SDSA\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“ps”]
[ADB] No uiautomator process found to kill, continuing…
[UiAutomator] Starting UIAutomator
[ADB] Creating ADB subprocess with args: ["-P",5037,"-s",“988919445333384831”,“shell”,“uiautomator”,“runtest”,“AppiumBootstrap.jar”,"-c",“io.appium.android.bootstrap.Bootstrap”,"-e",“pkg”,“com.android.chrome”,"-e",“disableAndroidWatchers”,false,"-e",“acceptSslCerts”,false]
[UiAutomator] UiAutomator exited unexpectedly with code 0, signal null
[UiAutomator] Moving to state ‘stopped’
[HTTP] <-- POST /wd/hub/session - - ms - -
[HTTP] --> POST /wd/hub/session {“capabilities”:[{“desiredCapabilities”:{“newCommandTimeout”:120,“browserName”:“Chrome”,“platformName”:“Android”,“deviceName”:“988919445333384831”,“launchTimeout”:“100000”,“version”:“7.0”}},{“requiredCapabilities”:{}}],“desiredCapabilities”:{“newCommandTimeout”:120,“browserName”:“Chrome”,“platformName”:“Android”,“deviceName”:“988919445333384831”,“launchTimeout”:“100000”,“version”:“7.0”},“requiredCapabilities”:{}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{“newCommandTimeout”:120,“browserName”:“Chrome”,“platformName”:“Android”,“deviceName”:“988919445333384831”,“launchTimeout”:“100000”,“version”:“7.0”},{},[{“desiredCapabilities”:{“newCommandTimeout”:120,“browserName”:“Chrome”,“platformName”:“Android”,“deviceName”:“988919445333384831”,“launchTimeout”:“100000”,“version”:“7.0”}},{“requiredCapabilities”:{}}],null,null]
[BaseDriver] Event ‘newSessionRequested’ logged at 1493692211445 (22:30:11 GMT-0400 (Eastern Daylight Time))
[Logcat] Logcat terminated with code 0, signal null
[Logcat] Logcat terminated with code 0, signal null
[Logcat] Logcat terminated with code 0, signal null
[HTTP] <-- POST /wd/hub/session - - ms - -

New to Appium, any help would be highly appreciated!
Thank you.