Support version Android N

Could anyone confirm whether appium supports the Android N? I’ve tried and was not able to run tests, and now cannot get either appium does not support it or I have problem with device.

4 Likes

Please send us the appium error logs to understand your issue.

org.openqa.selenium.WebDriverException at driver creation:
[MJSONWP] Encountered internal error running command: Error: Error executing adbExec. Original error: Command ‘/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s HT5ACJT00043 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 process._tickCallback (node.js:355:11)

I’m not sure whether it depends on appium. It’s possible that we have problems with device. That is why I asked confirmation about support Android N, would like to localize problem.

Which version of Appium are you running? What capabilities did you pass in when initializing the driver session?

Have you tried emulators (HT5ACJT00043 is a very strange ID for an emulator)?

I am also facing same issue … Don’t know if appium supports Android N ( dev preview 3)

[36minfoe[39m: [debug] executing cmd: C:\SDK\platform-tools\adb.exe -s ZX1G42793T push “C:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar” /data/local/tmp/
e[36minfoe[39m: [debug] Pushing settings apk to device…
e[36minfoe[39m: [debug] executing cmd: C:\SDK\platform-tools\adb.exe -s ZX1G42793T install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk”
e[36minfoe[39m: [debug] Stopping logcat capture
e[36minfoe[39m: [debug] Logcat terminated with code null, signal SIGTERM
e[36minfoe[39m: [debug] Sent shutdown command, waiting for UiAutomator to stop…
e[33mwarne[39m: UiAutomator did not shut down fast enough, calling it gone
e[36minfoe[39m: [debug] Cleaning up android objects
e[36minfoe[39m: [debug] Cleaning up appium session
e[31merrore[39m: Failed to start an Appium session, err was: Error: Command failed: C:\windows\system32\cmd.exe /s /c “C:\SDK\platform-tools\adb.exe -s ZX1G42793T 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.]

e[36minfoe[39m: [debug] Error: Command failed: C:\windows\system32\cmd.exe /s /c “C:\SDK\platform-tools\adb.exe -s ZX1G42793T 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)

e[36minfoe[39m: [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:\SDK\platform-tools\adb.exe -s ZX1G42793T 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:\SDK\platform-tools\adb.exe -s ZX1G42793T 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:\SDK\platform-tools\adb.exe -s ZX1G42793T 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}
e[36minfoe[39m: e[37m<-- POST /wd/hub/session e[39me[31m500e[39me[90m 10917.838 ms - 1261e[39m e[90me[39m
Exception in thread “main” org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Command failed: C:\windows\system32\cmd.exe /s /c “C:\SDK\platform-tools\adb.exe -s ZX1G42793T 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.]
) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 11.19 seconds
Build info: version: ‘2.53.0’, revision: ‘35ae25b’, time: ‘2016-03-15 17:00:58’
Driver info: io.appium.java_client.android.AndroidDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:43)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:39)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:69)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:78)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:67)
at com.appium.fwfiles.SetUpUtilities.startServerForAllDevices(SetUpUtilities.java:205)
at com.appium.fwfiles.SetUpUtilities.startExecution(SetUpUtilities.java:416)
at com.appium.driver.AutomationDriver.main(AutomationDriver.java:27)
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true

We do not use emulators on our project, only real devices (due to app restrictions). The capabilities are common, nothing special:
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, device.name)
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))

cheers

2 Likes

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

3 Likes

@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: https://github.com/appium/appium/issues/6665

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?

node_modules//appium/node_modules/appium-adb/lib/adb.js

Thank you @willosser