Appium version: 1_4_16
Find the solution in Csdn, according to this solution to solve the problem of melancholy, again record.
1. Locate the Adb.js file in Appium installation directory: Appium\node_modules\appium\node_modules\appium-adb\lib
2, open adb.js, you can use the Notepad++ editor and other open files (note: In the code changes when the first comment out the previous code, and add their own easy to identify the mark, in case there is a wiggle room after the error, or the code backup is also feasible), find the following code:
ADB.prototype.shell = function (cmd, CB) { if (Cmd.indexof ('"') = = = = 1 ) { '"'"'; } var ' ' + cmd; This . EXEC (ExecCmd, CB);};
Add the following code below this code:
ADB.prototype.shell_grep =function (cmd, grep, CB) {if(Cmd.indexof ('"') === -1) {cmd='"'+ cmd +'"'; } varExecCmd ='Shell'+ cmd +'| grep'+grep; This. EXEC (ExecCmd, CB);};
Find the following code again:
ADB.prototype.getPIDsByName =function (name, CB) {Logger.debug ("Getting All processes with '"+ name +"'"); This. Shell ("PS '"+ name +"'", function (err, stdout) {if(ERR)returnCB (ERR); StdOut=Stdout.trim (); varProcs = []; varoutlines = Stdout.split ("\ n"); Outlines.shift (); _.each (outlines, function (outline) {if(Outline.indexof (name)!==-1) {Procs.push (outline); } }); if(Procs.length <1) {Logger.debug ("No matching processes found"); returncbNULL, []); } varPIDs = []; _.each (procs, function (proc) {varMatch =/[^\t]+[\t]+ ([0-9]+)/. EXEC (proc); if(Match) {Pids.push (parseint (match[1],Ten)); } }); if(Pids.length!==procs.length) {varmsg ="Could not extract PIDs from PS output. PIDS:"+json.stringify (PIDs)+", procs:"+json.stringify (procs); returncbNewError (msg)); } CB (NULL, PIDs); });};
Comment out the above code and replace it with the following code:
ADB.prototype.getPIDsByName =function (name, CB) {Logger.debug ("Getting All processes with '"+ name +"'"); This. Shell_grep ("PS", name, function (err, stdout) {if(Err) {Logger.debug ("No matching processes found"); returncbNULL, []); } varPIDs = []; _.each (procs, function (proc) {varMatch =/[^\t]+[\t]+ ([0-9]+)/. EXEC (proc); if(Match) {Pids.push (parseint (match[1],Ten)); } }); if(Pids.length!==procs.length) {varmsg ="Could not extract PIDs from PS output. PIDS:"+json.stringify (PIDs)+", procs:"+json.stringify (procs); returncbNewError (msg)); } CB (NULL, PIDs); });};
3, restart the Appium, connected to the successful operation of the phone to see the resolution is OK
Appium Run Error command failed shell:............ps: ' Uiautomator ' solution on Android 7.0 Real machine