appium之安卓7.0环境搭建

左心房为你撑大大i 提交于 2020-01-23 01:28:47

appium 在安卓7.0的手机上运行上报错---------Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]

解决方法:

进入Appium安装目录,找到目录下的adb.js(D:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js)

adb.js 中1035 行(出错原因:this.shell("ps '" + name + "'", function (err, stdout) {对应执行的指令是ps 'uiautomator', Android7不支持这个指令格式,所以执行结果是bad pid 'uiautomator'

this.shell("ps '" + name + "'", function (err, stdout) {
  if (err) return cb(err);
  替换成
  this.shell_grep("ps", name, function (err, stdout) {
  if (err) {
  logger.debug("No matching processes found");
  return cb(null, []);
  }
并增加上面用到的shell_grep函数:
ADB.prototype.shell_grep = function (cmd, grep, cb) {
if (cmd.indexOf('"') === -1) {
cmd = '"' + cmd + '"';
}
var execCmd = 'shell ' + cmd + '| grep ' + grep;
this.exec(execCmd, cb);
};

  

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!