收到错误“INSTALL_FAILED_ALREADY_EXISTS:尝试在不先卸载的情况下重新安装io.appium.settings

时间:2017-07-13 21:22:00

标签: appium

使用代码通过Appium打开Amazon应用程序。但是得到错误INSTALL_FAILED_ALREADY_EXISTS:尝试重新安装io.appium.settings而不先卸载“。我该如何解决它。我使用Appium版本1.4.16.1和Android 7.0 moto G4 plus作为设备。

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”“ 无法安装C:\ Program Files(x86)\ Appium \ node_modules \ appium \ build \ settings_apk \ settings_apk-debug.apk: 失败[INSTALL_FAILED_ALREADY_EXISTS:尝试在未先卸载的情况下重新安装io.appium.settings。] )(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:31.43秒 构建信息:版本:'2.45.0',修订版:'32a636c',时间:'2015-03-05 22:01:35' 系统信息:主机:'nik-nik',ip:'192.168.84.1',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.8 .0_131' 驱动程序信息: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 个答案:

答案 0 :(得分:0)

您应首先从设备中删除Amazon应用程序,或者您应该更改所需的功能以使用已安装在设备上的应用程序。