Support version Android N

We do not use emulators on our project, only real devices (due to app restrictions). The capabilities are common, nothing special:
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, device.platform)
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, device.platformVersion)
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, ‘Appium’)
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 300)
capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, device.packageName)
capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, ‘com.oxagile.animationsample.LoginActivity’)

Appium v1.5.2 (REV f0aff2a69fdd83d2728443887ec0d89b8704e044)

Hmm… that’s definitely interesting. Do you also have any command line options you’re using when launching Appium?

I am also getting the same error -

[MJSONWP] Encountered internal error running command: Error: Error executing adbExec. Original error: Command ‘//adb -P 5037 -s ZX1G32693V install /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/io.appium.settings/bin/settings_apk-debug.apk’ exited with code 1{“stdout”:"",“stderr”:“Failed to install /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/io.appium.settings/bin/settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]\n”,“code”:1}
at ADB.execFunc$ (lib/tools/system-calls.js:189:13)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at run (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:104:47)
at /usr/local/lib/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:115:28
at flush (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/$.microtask.js:19:5)
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickCallback (node.js:349:13)

I found a workaround for this , look like for android N devices uiautomator process is not listed using ps command , ps command will return bad pid . this is not handled in adb.js

need to add below check to adb and it will work

go to adb.js (\node_modules\appium-adb\lib\adb.js)

and change line 1041 if ((outline.indexOf(name) !== -1) to if ((outline.indexOf(name) !== -1) && !(outline.indexOf(“bad pid”) > -1))



Would be good to fix it in appium before official release of Android N

@harigovind, the problem I found with not finding uiautomator is that appium is using a non-standard command line form of ps. It calls ps like this

ps “”

This is no longer supported on Android N and will always return an error whether or not the process is running. I am not proficient in writing node.js code, but I put in the following and it’s been working for me:

ADB.prototype.shell_grep = function (cmd, grep, cb) {
if (cmd.indexOf(‘"’) === -1) {
cmd = ‘"’ + cmd + ‘"’;
var execCmd = 'shell ’ + cmd + '| grep ’ + grep;
this.exec(execCmd, cb);

I then changed the code which searches for uiautomator

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

We are still using Appium 1.4.13 as we’ve had some initial problems with APpium 1.5.1. This solution is for a UNIX based system. It doesn’t assume there is grep installed on the device (a few devices have it, but most don’t), so it takes the output pipes it through grep on the test controller. This won’t work for a windows test server.

I don’t believe @harigovind’s solution solves the problem with not being able to install the two appium apks. I have a manual workaround for now in order to test Android N. I run the following command(s) before I start the appium server each time:

adb uninstall io.appium.settings; adb uninstall io.appium.unlock


@willosser, I too been working on 1.4.3 on windows . When we faced this problem just went through the logs and did a quick tweak . coz uninstalling two apks was not working for me . Anyways i am not claiming it to be “the generic solution” :slight_smile: . If your approach works then it’s fantastic…

@harigovind, the problem I see with your solution is that the ps command will always error out. If uiautomator is actually running, then it won’t take the proper action. But, as you say, if your approach works, then it’s fantastic. There are so many other problems I’m having with Android N…

@willosser… Agreed to your point.

I filed a bug for this:

I’m using Appium with Cucumber and I’m having the same issue. As a workaround I manually uninstall io.appium.settings and io.appium.unlock on the Before Cucumber hook.

Thanks for the details. I made the required updates in the node.js and it worked for me. Though I am wondering if there is an easy way to run adb uninstall io.appium.settings; adb uninstall io.appium.unlock in the config file.
Just to avoid manual steps.
I am using Java on Mac.
As you said there are lots of other issues I am also facing on Android 7 namely the WebViews are not working properly for me.

which node js file has to be updated with these changes?


Thank you @willosser

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
Appium :

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