0
votes

Using code for opening Amazon application through Appium. But getting error INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling". How can i solve it. I'm using Appium version 1.4.16.1 & Android 7.0 moto G4 plus as device.

package amazonApp;

import io.appium.java_client.android.AndroidDriver;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

public class App {
	
	private static AndroidDriver driver;
	
	public static void main(String[] args) throws MalformedURLException, InterruptedException {
		 
		File classpathRoot = new File(System.getProperty("user.dir"));
		
		File appDir = new File(classpathRoot, "/App/Amazon/");
		File app = new File(appDir, "amazon-india-online-shopping-12-2-0-300.apk");

		DesiredCapabilities capabilities = new DesiredCapabilities();
		capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
		capabilities.setCapability("deviceName", "ZY2239N792");
		capabilities.setCapability("platformVersion", "7.0");
		capabilities.setCapability("platformName", "Android");
		capabilities.setCapability("app", app.getAbsolutePath());
		capabilities.setCapability("appPackage", "in.amazon.mShop.android.shopping");
		capabilities.setCapability("appActivity", "com.amazon.mShop.home.HomeActivity");
		
		driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
		driver.findElementByName("Skip sign in").click();
		System.out.println("hii");
		driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
		
		Thread.sleep(10000);
		driver.quit();

	}

}
I'm getting error:-
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Command failed:

C:\Windows\system32\cmd.exe /s /c "C:\Users\nik\AppData\Local\Android\sdk\platform-tools\adb.exe -s ZY2239N792 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.] ) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 31.43 seconds Build info: version: '2.45.0', revision: '32a636c', time: '2015-03-05 22:01:35' System info: host: 'nik-nik', ip: '192.168.84.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_131' Driver info: io.appium.java_client.android.AndroidDriver

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:153)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:109)

at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:39)
at amazonApp.App.main(App.java:31)
1
Please update Appium version to 1.6.0 or use phone which is having android version 6 or below.shiv

1 Answers

0
votes

You should first remove Amazon app from device or you should change your desired capabilities to use the app installed on device already.