Parallell testing with uiautomator2 failed

I have following setup with a Testng file. It works smoothly with uiautomator, but doens’t work with uiautomator2. Second thread isn’t started. What can be the issue ?

@Test
@BeforeClass
public void startAppium(){
AppiumDriverLocalService service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder().usingAnyFreePort());
service.start();
appiumServiceUrl = service.getUrl().toString();
}
@Test
@BeforeMethod
@Parameters({ “device_id”,“device_name”,“platformVersion”, “platformName”})
public void prepareDeviceForAppium(String device_id, String device_name, String platformVersion, String platformName) throws Exception {
File classpathRoot = new File(System.getProperty(“user.dir”));
File appDir = new File(classpathRoot, “/src/test/resources/app/”);
File app = new File(appDir, );
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“deviceName”, device_name);
capabilities.setCapability(“udid”, device_id);
capabilities.setCapability(“appium-version”, “1.6.4”);
capabilities.setCapability(“platformName”, platformName);
capabilities.setCapability(“platformVersion”, platformVersion);
capabilities.setCapability(“automationName”, “uiautomator2”);
capabilities.setCapability(“app”, app.getAbsolutePath());
capabilities.setCapability(“appPackage”, ");
capabilities.setCapability(“appActivity”, );
capabilities.setCapability(“autoGrantPermissions”, true);
//capabilities.setCapability(“autoAcceptAlerts”, true);
capabilities.setCapability(“noReset”, true);
capabilities.setCapability(“fullReset”, false);

    driver = new AndroidDriver(new URL(appiumServiceUrl), capabilities);
    driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}

try this repo

Hi,

This is not an answer to my problem. I am interested in solving my setup, not in using your repo.

specify different systemPort caps

Thx, i’ll try that solution and try to randomize the choice of port, so each time a random free port is chosen.