Support version Android N

Such change cannot be made to latest appium-adb. [appium/appium-adb#172]
What will be the work around?

@rashiatry, either don’t use the latest, or wait for the fix.

Hello Need help I am getting the below error

A new session could not be created. (Original error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c “C:\Users\Hitesh.Seth\AppData\Local\Android\sdk\platform-tools\adb.exe -s ENU7N15B108961515 shell “ps ‘uiautomator’””

The appium settings are not getting installed on the phone.

Android 7
OS-Windows
Appium :1.4.16.1

Any update on the above issue… is that fixed ?

I’m still getting the error,

Device : Google Pixel XL
Version : 7.1

Failed to start an Appium session, err was: Error: Could not extract PIDs from ps output. PIDS: [], Procs: [“bad pid ‘uiautomator’”]

1 Like

same issue appium with C# while running on MAc os

2017-01-09 06:56:46:916 - info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Could not extract PIDs from ps output. PIDS: [], Procs: [“bad pid ‘uiautomator’”])”,“origValue”:“Could not extract PIDs from ps output. PIDS: [], Procs: [“bad pid ‘uiautomator’”]”},“sessionId”:null}

@rkn411, note that it has nothing to do with C#, but the implementation of the call to adb on the device.

1 Like

@willosser

As your suggested solution for UNIX based system, could you please help me for providing solution for Windows based system. I have try this solution for windows based system and it shows error: Failed to start an Appium session, err was: Device did not become ready in 5 secs; are you sure it’s powered on?

@him, but I have no experience working on a Windows system. If, however, you post the server logs from the failed run, we might be able to solve it.

info: [debug] executing cmd: C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce kill-server

info: [debug] Getting connected devices…
info: [debug] executing cmd: C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce devices
info: [debug] 1 device(s) connected
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce wait-for-device
error: Unhandled error: TypeError: undefined is not a function
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:942:16)
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:180:9)
at ChildProcess.exithandler (child_process.js:742:7)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1016:16)
at Process.ChildProcess._handle.onexit (child_process.js:1088:5) context: [POST /wd/hub/session {“desiredCapabilities”:{“newCommandTimeout”:“60000”,“platformVersion”:“7.0”,“deviceName”:“00a9afcf9f9319ce”,“platformName”:“Android”,“appActivity”:“com.projectname.activity.SplashActivity”,"appWaitActi]

info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
warn: UiAutomator did not shut down fast enough, calling it gone
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Device did not become ready in 5 secs; are you sure it’s powered on?
info: [debug] undefined
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created.”,“origValue”:“Device did not become ready in 5 secs; are you sure it’s powered on?”},“sessionId”:null}

Can you run this command manually? Does it work? Is this uuid the one reported by the connected device (assuming you only have one connected)?

Actually this is happening because I have made change in adb.js, I have uninstall my appium and install it once again and it works. but dose not work with android 7 devices.

As you can see from my comments above, I had to modify adb.js as well in order to get it to work on Android N

Getting the following error in server logs when trying to run tests on Android 7.0, appium 1.6.3:

Bad parameters: BadParametersError: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional":["requiredCap‌​abilities","capabili‌​ties","sessionId","i‌​d","sessionId","id",‌​"sessionId","id"]} and you sent ["capabilities"]

This solution helped me in setting up Android 7 in Moto G4 plus. I had to modify the adb.js of Appium 1.14.16.1 on Windows 7. Thank you! Cheers!

Can you paste your adb.js file here.
I also have Moto G4 Plus but updating it with the code given above didn’t solve my problem.
Please help

harigovind or any experts in this group, how you guys are debugging appium javascripts(adb.js) with Appium code(language bindings)? Meaning when you are debugging how you control from Appium code to respective java scripts?

FYI… i am very new to these development technologies and debugging into each of these applications.

Here you go,

  1. Go to adb.js in the path ‘node_modules//appium/node_modules/appium-adb/lib/adb.js’
    *Find the below
    ADB.prototype.shell = function (cmd, cb) {
    if (cmd.indexOf(’"’) === -1) {
    cmd = ‘"’ + cmd + ‘"’;
    }
    var execCmd = ‘shell ’ + cmd;
    this.exec(execCmd, cb);
    };
    Append the below
    ADB.prototype.shell_grep = function (cmd, grep, cb) {
    if (cmd.indexOf(’"’) === -1) {
    cmd = ‘"’ + cmd + ‘"’;
    }
    var execCmd = 'shell ’ + cmd + '| grep ’ + grep;
    this.exec(execCmd, cb);
    };

2 Find the 'ADB.prototype.getPIDsByName ’ and replace the whole section

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”);
return cb(null, []);
}
var pids = [];
_.each(procs, function (proc) {
var match = /[^\t ]+[\t ]+([0-9]+)/.exec(proc);
if (match) {
pids.push(parseInt(match[1], 10));
}
});
if (pids.length !== procs.length) {
var msg = "Could not extract PIDs from ps output. PIDS: " +
JSON.stringify(pids) + ", Procs: " + JSON.stringify(procs);
return cb(new Error(msg));
}
cb(null, pids);
});
};

Hope this works :slight_smile:

1 Like

Hi Manasa,

After doing above step still getting below error:

info: [debug] executing cmd: C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device…
info: [debug] executing cmd: C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce push “C:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar” /data/local/tmp/
info: [debug] Pushing settings apk to device…
info: [debug] executing cmd: C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk”
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
warn: UiAutomator did not shut down fast enough, calling it gone
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c “C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk””
Failed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]

info: [debug] Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c “C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk””
Failed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]

at ChildProcess.exithandler (child_process.js:751:12)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1016:16)
at Process.ChildProcess._handle.onexit (child_process.js:1088:5)

info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c "C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk""\nFailed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]\r\n)”,“killed”:false,“code”:1,“signal”:null,“cmd”:“C:\WINDOWS\system32\cmd.exe /s /c "C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk""”,“origValue”:“Command failed: C:\WINDOWS\system32\cmd.exe /s /c "C:\Data\AndriodSDK\sdk\platform-tools\adb.exe -s 00a9afcf9f9319ce install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk""\nFailed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]\r\n”},“sessionId”:null}
info: ← POST /wd/hub/session 500 9078.790 ms - 1333

Hi Manasa,

I followed you, however still not able to start app, getting following error : -

error: Unhandled error: ReferenceError: grep is not defined

at [object Object].ADB.shell (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:192:46)
at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:942:16)
at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:180:9)
at ChildProcess.exithandler (child_process.js:742:7)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1016:16)
at Socket.<anonymous> (child_process.js:1184:11)
at Socket.emit (events.js:107:17)
at Pipe.close (net.js:484:11) context: [POST /wd/hub/session {"capabilities":{"desiredCapabilities":{"appPackage":"svf.viewlift.com.test","app":"C:\\Users\\bhuvnesh.sharma\\workspace\\SVFAN\\app\\svf_release_buiild_v_1.0.016.apk","platformVersion":"7.0","browse]

info: [debug] executing cmd: C:\Users\bhuvnesh.sharma\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s ZY223P4F3Z kill-server
info: [debug] Getting connected devices…
info: [debug] executing cmd: C:\Users\bhuvnesh.sharma\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s ZY223P4F3Z devices
info: [debug] 1 device(s) connected
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: C:\Users\bhuvnesh.sharma\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s ZY223P4F3Z wait-for-device
error: Unhandled error: ReferenceError: grep is not defined
at [object Object].ADB.shell (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:192:46)
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:942:16)
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:180:9)
at ChildProcess.exithandler (child_process.js:742:7)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1016:16)
at Process.ChildProcess._handle.onexit (child_process.js:1088:5) context: [POST /wd/hub/session {“capabilities”:{“desiredCapabilities”:{“appPackage”:“svf.viewlift.com.test”,“app”:“C:\Users\bhuvnesh.sharma\workspace\SVFAN\app\svf_release_buiild_v_1.0.016.apk”,“platformVersion”:“7.0”,"browse]
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
warn: UiAutomator did not shut down fast enough, calling it gone
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Device did not become ready in 5 secs; are you sure it’s powered on?
info: [debug] undefined
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created.”,“origValue”:“Device did not become ready in 5 secs; are you sure it’s powered on?”},“sessionId”:null}
info: ← POST /wd/hub/session 500 48930.688 ms - 171

Please help…

Anybody else getting this error ?

Thanks