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

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM