首页 > 代码库 > appium之安卓7.0环境搭建

appium之安卓7.0环境搭建

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);
};

  

 

appium之安卓7.0环境搭建