Appium 1.4.13在Android 7上有bug
報(bào)錯(cuò):Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without firstuninstalling.]
原解決方案見:https://discuss.appium.io/t/support-version-android-n/10206/5
總結(jié)自己的解決方案:
原因:
1. adb.js 中1035 行this.shell("ps '" + name + "'", function (err, stdout) {
對應(yīng)執(zhí)行的指令是ps 'uiautomator', Android7不支持這個(gè)指令格式,所以執(zhí)行結(jié)果是bad pid'uiautomator'
目前Appium未對此進(jìn)行處理,所以需要修改此指令的執(zhí)行方式
即將
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函數(shù):
ADB.prototype.shell_grep = function (cmd, grep, cb) {
if (cmd.indexOf('"') === -1) {
cmd = '"' + cmd + '"';
}
var execCmd = 'shell ' + cmd + '| grep ' + grep;
this.exec(execCmd, cb);
};