无法启动Appium会话,错误是:错误:命令失败:

时间:2017-02-13 12:57:14

标签: android appium

我使用了Windows和Eclips。

Bellow class I我已经为测试写了:

公共类TestApp

{     AppiumDriver驱动程序;

@Test
public void testapp()  throws MalformedURLException, InterruptedException
{
    File app =new File(System.getProperty("user.dir")+"\\apks\\sigiriya-debug.apk");

      // DesiredCapabilities capabilities = new DesiredCapabilities();
      DesiredCapabilities capabilities =DesiredCapabilities.android();
      //capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
      capabilities.setCapability("deviceName","google-pixel-FA6C10301834");
      capabilities.setCapability("platformVersion", "7.1.1");
      capabilities.setCapability("platformName","Android");
      capabilities.setCapability("app", app.getAbsolutePath());


      //  capabilities.setCapability("appPackage", "com.whatsapp");
      //  capabilities.setCapability("appActivity", "com.whatsapp.Main");
      //  dr = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
      driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
     // driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);


      // clicking
      Thread.sleep(10000);

}
  } 

当我运行代码时,Apk已安装到我的手机上。但是在appium控制台中跟随错误日志测试失败

登录Appium:

  

info: - > POST / wd / hub / session {" desiredCapabilities":{" app":" C:\ Users \ uwickdi \ workspace \ Mobile \ eselenium.liverPool.testmob \ apks \锡吉里亚-debug.apk"" platformVersion":" 7.1.1"" browserName":"机器人"&#34 ; platformName":" Android和#34;"版本":""" DEVICENAME":"由Google像素 - FA6C10301834""平台":"机器人"}}   info:客户端用户代理字符串:Apache-HttpClient / 4.3.3(java 1.5)   info:[debug]提供了以下所需功能,但appium无法识别。它们将被传递给在此服务器上运行的任何其他服务。 :版本,平台   info:[debug]没有appActivity所需的功能或服务器参数。从apk解析。   info:[debug]没有appPackage所需的功能或服务器参数。从apk解析。   info:[debug]使用所需大写的本地应用程序:C:\ Users \ uwickdi \ workspace \ Mobile \ eselenium.liverPool.testmob \ apks \ sigiriya-debug.apk   info:[debug]创建新的appium会话622e973b-f97e-4961-8c0b-c79e13067803   info:启动android appium   info:[debug]获取Java版本   info:Java版本是:1.8.0_101   info:[debug]检查adb是否存在   info:[debug]使用来自C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe的adb   info:[debug]从应用程序清单中解析包和活动   info:[debug]检查aapt是否存在   info:[debug]使用来自C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ build-tools \ 25.0.2 \ aapt.exe的aapt   info:[debug]从清单中提取包和启动活动。   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ build-tools \ 25.0.2 \ aapt.exe dump badging C:\ Users \ uwickdi \ workspace \ Mobile \ eselenium.liverPool .testmob \的APK \锡吉里亚,debug.apk   info:[debug] badging package:com.pearsoned.sigiriya   info:[debug] badging act:com.pearsoned.sigiriya.view.activity.ActivityDecksView   info:[debug]解析的包和活动是:com.pearsoned.sigiriya / com.pearsoned.sigiriya.view.activity.ActivityDecksView   info:[debug]使用快速重置?真正   info:[debug]准备会话设备   info:[debug]检查app是否确实存在   info:检索设备   info:[debug]试图找到一个连接的Android设备   info:[debug]获取连接设备...   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe devices   info:[debug] 1个设备已连接   info:找到设备FA6C10301834   info:[debug]将设备ID设置为FA6C10301834   info:[debug]等待设备准备就绪并响应shell命令(timeout = 5)   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834 wait-for-device   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834 shell" echo' ready'&#34 ;   info:[debug]启动logcat捕获   info:[debug]获取设备API级别   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834 shell" getprop ro.build.version.sdk"   info:[debug]设备处于API级别25   info:设备API级别为:25   info:[debug]为语言提取字符串:default   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834 shell" getprop persist.sys.language"   info:[debug]当前设备persist.sys.language:   info:[debug] java -jar" C:\ Program Files(x86)\ Appium \ node_modules \ appium \ node_modules \ appium-adb \ _jars \ appium_apk_tools.jar" " stringsFromApk" " C:\用户\ uwickdi \工作空间\移动\ eselenium.liverPool.testmob \的apk \锡吉里亚-debug.apk" " C:\用户\ uwickdi \应用程序数据\本地\ TEMP \ com.pearsoned.sigiriya"   info:[debug]从转换的strings.json中读取字符串   info:[debug]将语言设置为默认值   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834 push" C:\ Users \ uwickdi \ AppData \ Local \ Temp \ com.pearsoned.sigiriya \ strings.json" /数据/本地/ tmp目录   info:[debug]检查aapt是否存在   info:[debug]使用来自C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ build-tools \ 25.0.2 \ aapt.exe的aapt   info:[debug]从清单中检索进程。   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ build-tools \ 25.0.2 \ aapt.exe dump xmltree C:\ Users \ uwickdi \ workspace \ Mobile \ eselenium.liverPool .testmob \ apks \ sigiriya-debug.apk AndroidManifest.xml   info:[debug]将应用程序进程设置为:com.pearsoned.sigiriya   info:[debug]不卸载应用程序,因为服务器未启动--full-reset   info:[debug]检查C:\ Users \ uwickdi \ workspace \ Mobile \ eselenium.liverPool.testmob \ apks \ sigiriya-debug.apk的应用程序证书。   info:[debug]执行cmd:java -jar" C:\ Program Files(x86)\ Appium \ node_modules \ appium \ node_modules \ appium-adb \ jars \ verify.jar" C:\ Users \用户uwickdi \工作空间\移动\ eselenium.liverPool.testmob \的apk \锡吉里亚-debug.apk   info:[debug]应用程序已签名。   info:[debug] Zip-aligning C:\ Users \ uwickdi \ workspace \ Mobile \ eselenium.liverPool.testmob \ apks \ sigiriya-debug.apk   info:[debug]检查zipalign是否存在   info:[debug]在C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ build-tools \ 25.0.2 \ zipalign.exe中使用zipalign   info:[debug] Zip-aligning apk。   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ build-tools \ 25.0.2 \ zipalign.exe -f 4 C:\ Users \ uwickdi \ workspace \ Mobile \ eselenium。 liverPool.testmob \ apks \ sigiriya-debug.apk C:\ Users \ uwickdi \ AppData \ Local \ Temp \ 117113-3596-12b9r95 \ appium.tmp   info:[debug] app的MD5是8ded8f0bf024cef65fdef392e13505bb   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834 shell" ls /data/local/tmp/8ded8f0bf024cef65fdef392e13505bb.apk&# 34;   info:[debug]获取com.pearsoned.sigiriya的安装状态   info:[debug]获取设备API级别   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834 shell" getprop ro.build.version.sdk"   info:[debug]设备处于API级别25   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834 shell" pm list packages -3 com.pearsoned.sigiriya&#34 ;   info:[debug]安装了App   信息:已安装应用程序,重置应用程序   info:[debug]运行快速重置(停止和清除)   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834 shell" am force-stop com.pearsoned.sigiriya"   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834 shell" pm clear com.pearsoned.sigiriya"   info:[debug]转发系统:4724到设备:4724   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834 forward tcp:4724 tcp:4724   info:[debug]将appium bootstrap推送到设备...   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834 push" C:\ Program Files(x86)\ Appium \ node_modules \ appium \构建\ android_bootstrap \ AppiumBootstrap.jar" /数据/本地的/ tmp /   info:[debug]将设置apk推送到设备...   info:[debug]执行cmd:C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834安装" C:\ Program Files(x86)\ Appium \ node_modules \ appium \构建\ settings_apk \ settings_apk-debug.apk"   info:[debug]停止logcat捕获   info:[debug] Logcat终止,代码为null,信号为SIGTERM   info:[debug]发送shutdown命令,等待UiAutomator停止...   警告:UiAutomator没有足够快地关闭,称它已经消失了   info:[debug]清理android对象   info:[debug]清理appium会话   info:[debug]错误:命令失败:C:\ Windows \ system32 \ cmd.exe / s / c" C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834安装" 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。]

at ChildProcess.exithandler (child_process.js:751:12)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1016:16)
at Process.ChildProcess._handle.onexit (child_process.js:1088:5)
     

info:[debug]响应客户并出现错误:{" status":33," value":{" message":" A无法创建新会话。 (原始错误:命令失败:C:\ Windows \ system32 \ cmd.exe / s / c \" C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834安装\" C:\ Program Files(x86)\ Appium \ node_modules \ appium \ build \ settings_apk \ settings_apk-debug.apk \" \" \ n无法安装C:\ Program Files (x86)\ Appium \ node_modules \ appium \ build \ settings_apk \ settings_apk-debug.apk:失败[INSTALL_FAILED_ALREADY_EXISTS:尝试在未先卸载的情况下重新安装io.appium.settings。] \ r \ n)",& #34;杀死":假,"代码":1,"信号":空," CMD":" C:\的Windows \ system32 \ cmd.exe / s / c \" C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834 install \" C:\ Program Files (x86)\ Appium \ node_modules \ appium \ build \ settings_apk \ settings_apk-debug.apk \" \""," origValue":"命令失败: C:\ Windows \ system32 \ cmd.exe / s / c \" C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834安装l \" C:\ Program Files(x86)\ Appium \ node_modules \ appium \ build \ settings_apk \ settings_apk-debug.apk \" \" \ n无法安装C:\ Program Files( x86)\ Appium \ node_modules \ appium \ build \ settings_apk \ settings_apk-debug.apk:失败[INSTALL_FAILED_ALREADY_EXISTS:尝试在未先卸载的情况下重新安装io.appium.settings。] \ r \ n"},&#34 ;的sessionId":空}   错误:无法启动Appium会话,错误是:错误:命令失败:C:\ Windows \ system32 \ cmd.exe / s / c" C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s FA6C10301834安装" 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。]

     

info:< - POST / wd / hub / session 500 21049.722 ms - 1390

感谢您的帮助以解决这个问题。 谢谢

1 个答案:

答案 0 :(得分:0)

如果您看到错误,请确认您的APK文件是未签名的。 其次,错误是

  

C:\用户\ uwickdi \工作空间\移动\ eselenium.liverPool.testmob \的apk \锡吉里亚-debug.apk   C:\ Users \用户uwickdi \应用程序数据\本地的\ Temp \ 117113-3596-12b9r95 \ appium.tmp   info:[debug] app5的MD5是8ded8f0bf024cef65fdef392e13505bb信息:   [debug]执行cmd:   C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s   FA6C10301834外壳" ls   /data/local/tmp/8ded8f0bf024cef65fdef392e13505bb.apk"信息:[调试]   获取com.pearsoned.sigiriya信息的安装状态:[debug]   获取设备API级别信息:[debug]执行cmd:   C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s   FA6C10301834 shell" getprop ro.build.version.sdk" info:[debug]设备   是API级别25信息:[debug]执行cmd:   C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s   FA6C10301834 shell" pm list packages -3 com.pearsoned.sigiriya"信息:   [debug]应用已安装信息:已安装应用,重置应用   info:[debug]运行快速重置(停止和清除)信息:[debug]   执行cmd:   C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s   FA6C10301834 shell" am force-stop com.pearsoned.sigiriya"信息:   [debug]执行cmd:   C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s   FA6C10301834 shell" pm clear com.pearsoned.sigiriya"信息:[调试]   转发系统:4724到设备:4724信息:[debug]执行cmd:   C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s   FA6C10301834 forward tcp:4724 tcp:4724 info:[debug]推送appium   bootstrap to device ... info:[debug] execution cmd:   C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s   FA6C10301834推送" C:\ Program Files   (86)\ Appium \ node_modules \ appium \构建\ android_bootstrap \ AppiumBootstrap.jar"   / data / local / tmp / info:[debug]将设置apk推送到设备... info:   [debug]执行cmd:   C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s   FA6C10301834安装" C:\ Program Files   (86)\ Appium \ node_modules \ appium \建立\ settings_apk \ settings_apk-debug.apk"   info:[debug]停止logcat捕获信息:[debug] Logcat终止   代码为null,信号SIGTERM info:[debug]发送shutdown命令,   等待UiAutomator停止......警告:UiAutomator没有关闭   叫它消失的信息:[debug]清理android对象   info:[debug]清理appium会话信息:[debug]错误:命令   失败:C:\ Windows \ system32 \ cmd.exe / s / c   " C:\ Users \ uwickdi \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s   FA6C10301834安装" C:\ Program Files   (86)\ Appium \ node_modules \ appium \建立\ settings_apk \ settings_apk-debug.apk""   无法安装C:\ Program Files   (86)\ Appium \ node_modules \ appium \构建\ settings_apk \ settings_apk-debug.apk:

失败[INSTALL_FAILED_ALREADY_EXISTS:尝试重新安装

  

io.appium.settings没有先卸载。]

观察错误消息中的最后两行。 在运行代码之前卸载原始应用程序。因此,可以在开发模式下重新安装该应用程序。