FAILED CONFIGURATION: @BeforeTest setUp
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Command failed: C:\Windows\system32\cmd.exe /s /c ““D:\android sdk\platform-tools\adb.exe” -s ZY223Z4CNG install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk””
Failed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]
Logs :
e[36minfoe[39m: Installing App
e[36minfoe[39m: [debug] executing cmd: “D:\android sdk\platform-tools\adb.exe” -s ZY223Z4CNG shell “mkdir -p /data/local/tmp/”
e[36minfoe[39m: [debug] Removing any old apks
e[36minfoe[39m: [debug] executing cmd: “D:\android sdk\platform-tools\adb.exe” -s ZY223Z4CNG shell “ls /data/local/tmp/*.apk”
e[36minfoe[39m: [debug] executing cmd: “D:\android sdk\platform-tools\adb.exe” -s ZY223Z4CNG shell rm “/data/local/tmp/5a45a4e62693f277547d14a7953631a1.apk” && rm “/data/local/tmp/apk1499671341128.apk”
e[36minfoe[39m: [debug] executing cmd: “D:\android sdk\platform-tools\adb.exe” -s ZY223Z4CNG push “D:\Automation_Project\Dublabs_Auto\app\Android\kutztowntest-2.2.09-uat.apk” /data/local/tmp/7a5283f854c744e5cf86aa6b7ef5d182.apk
e[36minfoe[39m: [debug] Uninstalling com.dub.app.kutztowntest
e[36minfoe[39m: [debug] executing cmd: “D:\android sdk\platform-tools\adb.exe” -s ZY223Z4CNG shell “am force-stop com.dub.app.kutztowntest”
e[36minfoe[39m: [debug] executing cmd: “D:\android sdk\platform-tools\adb.exe” -s ZY223Z4CNG uninstall com.dub.app.kutztowntest
e[36minfoe[39m: [debug] App was uninstalled
e[36minfoe[39m: [debug] executing cmd: “D:\android sdk\platform-tools\adb.exe” -s ZY223Z4CNG shell “pm install -r /data/local/tmp/7a5283f854c744e5cf86aa6b7ef5d182.apk”
e[36minfoe[39m: [debug] Forwarding system:4724 to device:4724
e[36minfoe[39m: [debug] executing cmd: “D:\android sdk\platform-tools\adb.exe” -s ZY223Z4CNG forward tcp:4724 tcp:4724
e[36minfoe[39m: [debug] Pushing appium bootstrap to device…
e[36minfoe[39m: [debug] executing cmd: “D:\android sdk\platform-tools\adb.exe” -s ZY223Z4CNG push “C:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar” /data/local/tmp/
e[36minfoe[39m: [debug] Pushing settings apk to device…
e[36minfoe[39m: [debug] executing cmd: “D:\android sdk\platform-tools\adb.exe” -s ZY223Z4CNG install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk”
e[36minfoe[39m: [debug] Stopping logcat capture
e[36minfoe[39m: [debug] Logcat terminated with code null, signal SIGTERM
e[36minfoe[39m: [debug] Sent shutdown command, waiting for UiAutomator to stop…
e[33mwarne[39m: UiAutomator did not shut down fast enough, calling it gone
e[31merrore[39m: Failed to start an Appium session, err was: Error: Command failed: C:\Windows\system32\cmd.exe /s /c ““D:\android sdk\platform-tools\adb.exe” -s ZY223Z4CNG install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk””
Failed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]
Configuration:
Appium v: 1.4.64
Device OS : Moto G5(OS7)
Please let me help to troubleshoot this problem.
with Android 7 when you manually uninstall app from main screen it getting disabled instead really uninstalled. try to remove your app from phone in app manager and retry.
@Aleksei
I followed your steps as you mentioned but getting the same issue. If you see attached logs in above comment, There is first uninstalling the app and then installed, and after that give the error. And I am able to see the app is installed on the device through the appium.
The Same code is working fine on OS5/6 even app is already installed in the device.
Is Appium 1.4.64 support OS7?
@rahulmittal1487 i tried with appium v1.6.6 and did not met problem with Android API25 (7.1) using old automation capability. but starting with android O (API26, v8.0) old automation does not work and we need migrate to ANDROID_UIAUTOMATOR2
Thanks!! It might be Appium version issue. could u let me know how can I update 1.4.16 to 1.6.6? Please provide me a link to download appium server file with V 1.6.6
i see you are with windows:
- download nodeJS and install -> https://nodejs.org/en/
- start command prompt and install latest appium with “npm install -g appium@beta”
@Aleksei Yes, I have already done this process and having updated appium v using node command. But when I am executing scripts then there is showing appium v1.4.16 in logs. If see in C:\Program Files (x86)\Appium then there is also showing old version as 1.4.16. Any idea?
how you start appium in code? you need to start it with command line way.
you can test: run command line and type “appium”. what version shown?
@Aleksei
I am starting appium in code using below code then also showing V 1.4.16
appiumService = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.usingDriverExecutable(
new File(appiumInstallationDir + File.separator + “Appium” + File.separator + “node.exe”))
.withAppiumJS(new File(appiumInstallationDir + File.separator + “Appium” + File.separator
+ “node_modules” + File.separator + “appium” + File.separator + “bin” + File.separator
+ “appium.js”)));
appiumService.start();
“appiumInstallationDir” with npm install it is somesing like: “C:\Users{USER}\AppData\Roaming\npm”
@Aleksei
Hi, I have changed path as u suggested but getting below error.
java.lang.IllegalStateException: The driver executable does not exist: C:\Users\rahul\AppData\Roaming\npm\Appium\node.exe
Cause it does not exist. Or exists in another path. Check the folder. Also you can try to start “appium.cmd” intead of “*.js”.
I am with mac OS. At home with windows i just starting manuallly whan need to check something quickly. Also you can start as exec as java code with same “appium.cmd”
@Aleksei
I have set the cmd path and execute but some syntax error is coming. could u send me the code to run appium in the code. I think, some missing things could be noticed.Thanks
@rahulmittal1487 something like:
List list = new ArrayList<String>();
if (System.getProperty("os.name").contains("Windows")) {
list.add("appium.cmd");
} else {
list.add("appium");
}
list.add("--log-level");
list.add("error");
list.add("--port");
list.add(port); // e.g. port = "4725" or whatever you like. you should use it later when start driver.
list.add("--bootstrap-port");
list.add(String.valueOf(Integer.parseInt(port) + 1000));
list.add("--command-timeout");
list.add("90");
list.add("--session-override");
list.add("--log-timestamp");
System.out.println(" start appium as: " + list.toString());
try {
ProcessBuilder pb1 = new ProcessBuilder(list);
pb1.redirectErrorStream(true);
pb1.redirectOutput(ProcessBuilder.Redirect.INHERIT);
appium_Process = pb1.start();
// here you may add some appium start detection OR simple Thread.sleep(10000) = 10sec
System.out.println(" appium server started");
} catch (Exception e) {
System.out.println(" appium server start FAILED");
e.printStackTrace();
}